<template>
  <pageTabelLayout>
    <template #pageHeader>
      <div class="search-form isheader" v-if="headerShow">
        <div>
          <a-form size="mini" v-if="tabsKeys != 5" :model="pageData" layout="inline">
                <CorporateSectorCascader
                  :configCascader="configCascader2"
                  @changeCascader="changeCascader2"
                />
                <a-form-item label="仓库" label-col-flex="80px">
                  <a-select
                    popup-container="html"
                    class="bacClass"
                    :style="{ width: '200px' }"
                    v-model="pageData.b"
                    allow-clear
                    @change="whChange"
                  >
                    <a-option v-for="item in fhWhList" :value="item.id">
                      {{ item.warehouseName }}
                    </a-option>
                  </a-select>
                </a-form-item>
                <a-form-item label="原料编号" label-col-flex="80px">
                  <a-input
                    allow-clear
                    :style="{ width: '200px' }"
                    class="bacClass"
                    v-model="pageData.yarnCode"
                  />
                </a-form-item>
                <a-form-item label="原料名称" label-col-flex="80px">
                  <a-input
                    allow-clear
                    :style="{ width: '200px' }"
                    class="bacClass"
                    v-model="pageData.yarnName"
                  />
                </a-form-item>
                <a-form-item label="纱牌" label-col-flex="80px">
                  <a-input
                    allow-clear
                    :style="{ width: '224px' }"
                    class="bacClass"
                    v-model="pageData.yarnBrand"
                  />
                </a-form-item>
                <a-form-item label-col-flex="80px" label="纱批">
                  <a-input
                    allow-clear
                    :style="{ width: '224px' }"
                    class="bacClass"
                    v-model="pageData.productionBatch"
                  />
                </a-form-item>
                <a-form-item label="等级" label-col-flex="80px">
                  <a-input
                    allow-clear
                    :style="{ width: '200px' }"
                    class="bacClass"
                    v-model="pageData.level"
                  />
                </a-form-item>
                <a-form-item label="单据类型" label-col-flex="80px" v-if="tabsKeys == 1">
                  <a-select
                    popup-container="html"
                    class="bacClass"
                    :style="{ width: '200px' }"
                    v-model="pageData.audit_state"
                    allow-clear
                  >
                    <!-- <a-option :value="0">普通调拨单</a-option> -->
                    <a-option :value="0">未审核</a-option>
                    <a-option :value="1">已审核入库</a-option>
                  </a-select>
                </a-form-item>
                <a-form-item label="入库类型" label-col-flex="80px" v-if="tabsKeys == 1">
                  <a-select
                    popup-container="html"
                    class="bacClass"
                    style="width:210px"
                    v-model="pageData.inStockTypes"
                    allow-clear
                    multiple
                    :max-tag-count="1"
                    @focus="getInStock"
                  >
                    <a-option v-for="item in pageData.inStockList" :value="item" :key="item">
                      {{ item }}
                    </a-option>
                  </a-select>
                </a-form-item>
                <a-form-item label="单据类型" label-col-flex="80px" v-if="tabsKeys == 3 || tabsKeys == 4">
                  <a-select
                    popup-container="html"
                    class="bacClass"
                    :style="{ width: '200px' }"
                    v-model="pageData.orderType"
                    allow-clear
                  >
                    <!-- <a-option :value="0">普通调拨单</a-option> -->
                    <a-option :value="1">加工出库单</a-option>
                    <a-option :value="2">加工领料单</a-option>
                    <a-option :value="3">加工收货单</a-option>
                    <a-option :value="4">纱线转让单</a-option>
                    <a-option :value="5">采购退货单</a-option>
                  </a-select>
                </a-form-item>
                <a-form-item label="来源单号" label-col-flex="80px" v-if="tabsKeys == 3 || tabsKeys == 4">
                  <a-input
                    allow-clear
                    :style="{ width: '200px' }"
                    class="bacClass"
                    v-model="pageData.sourceNumber"
                  />
                </a-form-item>
                <a-form-item label-col-flex="80px" label="日期">
                  <a-range-picker
                    popup-container="html"
                    :style="{ width: '240px' }"
                    class="bacClass"
                    @clear="onClear"
                    allow-clear
                    v-model="pageData.dropDownTime"
                  />
                </a-form-item>
          </a-form>
          <a-form size="mini" v-else :model="pageData" layout="inline">
            <a-form-item label="退料单号" label-col-flex="80px">
              <a-input
                allow-clear
                :style="{ width: '200px' }"
                class="bacClass"
                v-model="pageData.materialReturnCode"
              />
            </a-form-item>
            <a-form-item label="织布单号" label-col-flex="80px">
              <a-input
                allow-clear
                :style="{ width: '200px' }"
                class="bacClass"
                v-model="pageData.prodCode"
              />
            </a-form-item>
            <a-form-item label="客户" label-col-flex="80px">
              <a-input
                allow-clear
                :style="{ width: '200px' }"
                class="bacClass"
                v-model="pageData.khName"
              />
            </a-form-item>
            <a-form-item label="日期" label-col-flex="80px">
              <a-range-picker
                popup-container="html"
                :style="{ width: '250px' }"
                class="bacClass"
                @clear="onClear1"
                allow-clear
                v-model="pageData.dropDownTime1"
              />
            </a-form-item>
          </a-form>
        </div>
      </div>

      <div class="my-divisders">
        <a-divider orientation="center">
          <icon-double-up
            v-if="headerShow"
            @click="headerShow = false"
            :strokeWidth="2"
            :size="18"
          />
          <icon-double-down v-else @click="headerShow = true" :strokeWidth="2" :size="18" />
        </a-divider>
      </div>
      <div style="text-align: end">
        <Toolbar
          class="gesture"
          :items="toolbarList"
          @select="selectHandler"
          @reders="redersOut"
          @del="delSles"
          @audit="audits"
          @xzylRk="xzylRks"
          @cancelAudit="cancelAudit"
        >
        </Toolbar>
      </div>
      <div class="gang"></div>
    </template>
    <template #pageTabel>
      <a-tabs
        :lazy-load="true"
        :justify="true"
        :default-active-key="tabsKeys"
        @change="tabsChanges"
      >
        <a-tab-pane title="入库单管理" :key="1">
          <AgGridVuesCopys
            :rowHeight="33"
            :headerHeight="33"
            :suppressCopyRowsToClipboard="true"
            :suppressDragLeaveHidesColumns="true"
            rowSelection="multiple"
            @grid-ready="gridReady"
            @columnResized="onColumnResized"
            @columnMoved="onColumnMoved"
            @columnVisible="onColumnVisible"
            style="height: calc(100% - 45px)"
            :defaultColDef="defaultColDef"
            class="ag-theme-alpine"
            :rowData="tableDataList"
            :columnDefs="tc"
            :localeText="localeText1"
          ></AgGridVuesCopys>
          <paginationCopys
            :page-size-options="pagingList1"
            :total="fySelet2.total"
            show-total
            show-jumper
            show-page-size
            @change="PageSize2"
            @page-size-change="change2"
            style="justify-content: center"
            :page-size="fySelet2.size"
            :current="fySelet2.page"
          />
        </a-tab-pane>
        <a-tab-pane title="采购收货待处理" :key="2">
          <AgGridVuesCopys
            :rowHeight="33"
            :headerHeight="33"
            :suppressCopyRowsToClipboard="true"
            :suppressDragLeaveHidesColumns="true"
            rowSelection="multiple"
            @grid-ready="gridReady3"
            @columnResized="onColumnResized3"
            @columnMoved="onColumnMoved3"
            @columnVisible="onColumnVisible3"
            style="height: calc(100% - 45px)"
            :defaultColDef="defaultColDef3"
            class="ag-theme-alpine"
            :rowData="tableDataList3"
            :columnDefs="tc3"
            :localeText="localeText1"
          >
          </AgGridVuesCopys>
          <paginationCopys
            :page-size-options="pagingList1"
            :total="fySelet3.total"
            show-total
            show-jumper
            show-page-size
            @change="PageSize3"
            @page-size-change="change3"
            style="justify-content: center"
            :page-size="fySelet3.size"
            :current="fySelet3.page"
          />
        </a-tab-pane>
        <a-tab-pane title="调拨入库待处理" :key="3">
          <AgGridVuesCopys
            :rowHeight="33"
            :headerHeight="33"
            :suppressCopyRowsToClipboard="true"
            :suppressDragLeaveHidesColumns="true"
            rowSelection="multiple"
            @grid-ready="gridReady2"
            @columnResized="onColumnResized2"
            @columnMoved="onColumnMoved2"
            @columnVisible="onColumnVisible2"
            style="height: calc(100% - 45px)"
            :defaultColDef="defaultColDef2"
            class="ag-theme-alpine"
            :rowData="tableDataList2"
            :columnDefs="tc2"
            :localeText="localeText1"
          >
          </AgGridVuesCopys>
          <paginationCopys
            :page-size-options="pagingList1"
            :total="fySelet.total"
            show-total
            show-jumper
            show-page-size
            @change="PageSize"
            @page-size-change="change"
            style="justify-content: center"
            :page-size="fySelet.size"
            :current="fySelet.page"
          />
        </a-tab-pane>
        <a-tab-pane title="调拨入库已处理" :key="4">
          <AgGridVuesCopys
            :rowHeight="33"
            :headerHeight="33"
            :suppressCopyRowsToClipboard="true"
            :suppressDragLeaveHidesColumns="true"
            rowSelection="multiple"
            @grid-ready="gridReady4"
            @columnResized="onColumnResized4"
            @columnMoved="onColumnMoved4"
            @columnVisible="onColumnVisible4"
            style="height: calc(100% - 45px)"
            :defaultColDef="defaultColDef2"
            class="ag-theme-alpine"
            :rowData="tableDataList4"
            :columnDefs="tc2"
            :localeText="localeText1"
          >
          </AgGridVuesCopys>
          <paginationCopys
            :page-size-options="pagingList1"
            :total="fySelet4.total"
            show-total
            show-jumper
            show-page-size
            @change="PageSize4"
            @page-size-change="change4"
            style="justify-content: center"
            :page-size="fySelet4.size"
            :current="fySelet4.page"
          />
        </a-tab-pane>
        <a-tab-pane title="车间退料入库" :key="5">
          <AgGridVuesCopys
            :rowHeight="33"
            :headerHeight="33"
            :suppressCopyRowsToClipboard="true"
            :suppressDragLeaveHidesColumns="true"
            rowSelection="multiple"
            @grid-ready="gridReady5"
            @columnResized="onColumnResized5"
            @columnMoved="onColumnMoved5"
            @columnVisible="onColumnVisible5"
            style="height: calc(100% - 45px)"
            :defaultColDef="defaultColDef2"
            class="ag-theme-alpine"
            :rowData="tableDataList5"
            :columnDefs="tc5"
            :localeText="localeText1"
          >
          </AgGridVuesCopys>
          <paginationCopys
            :page-size-options="pagingList1"
            :total="fySelet6.total"
            show-total
            show-jumper
            show-page-size
            @change="PageSize6"
            @page-size-change="change6"
            style="justify-content: center"
            :page-size="fySelet6.size"
            :current="fySelet6.page"
          />
        </a-tab-pane>
      </a-tabs>
    </template>

    <a-modal
      v-model:visible="cgOut.visible"
      :on-before-ok="cgHandleOk"
      @cancel="cadelvs"
      fullscreen
      :mask-closable="false"
    >
      <template #title>
        {{ cgOut.title }}
      </template>
      <AgGridVuesCopys
        :rowHeight="33"
        :headerHeight="33"
        :suppressCopyRowsToClipboard="true"
        :suppressDragLeaveHidesColumns="true"
        rowSelection="multiple"
        @grid-ready="cgColumns2Ready"
        @columnResized="onColumnResized"
        @columnMoved="onColumnMoved"
        @columnVisible="onColumnVisible"
        style="height: 70vh; margin-top: 10px"
        :defaultColDef="defaultColDef"
        class="ag-theme-alpine"
        :rowData="cgData2"
        :columnDefs="cgColumns2"
        :localeText="localeText1"
      ></AgGridVuesCopys>
    </a-modal>
    <!-- 新增原料入库弹窗 -->
    <a-drawer
      ok-text="入库"
      cancel-text="关闭"
      :drawer-style="{ zIndex: 999 }"
      :mask-closable="false"
      unmount-on-close
      popup-container=".arco-tabs-content"
      :height="'90%'"
      :visible="dbPageDate.showAdd"
      @ok="sideOk"
      placement="bottom"
      @cancel="sideNo"
    >
      <template #title>
        {{ dbPageDate.titles }}
      </template>
      <a-form size="mini" :model="pageData" layout="inline">
        <!-- <a-form-item label="公司">
                  <a-input allow-clear :style="{ width: '200px' }" class="bacClass" v-model="pageData.a" />
              </a-form-item> -->
        <CorporateSectorCascader
          ref="setcorDisabledRefs"
          :configCascader="configCascader"
          @changeCascader="changeCascader"
        />
        <a-form-item label="仓库" :rules="[{ required: true, message: '仓库必填' }]" field="g">
          <a-select
            popup-container="html"
            class="bacClass"
            :style="{ width: '10rem' }"
            v-model="pageData.g"
            allow-clear
            :disabled="cgData3.length > 0"
          >
            <a-option v-for="item in fhWhList" :value="item.id + '-' + item.warehouseName">
              {{ item.warehouseName }}
            </a-option>
          </a-select>
        </a-form-item>
        <a-form-item
          label="入库类型"
          :rules="[{ required: true, message: '入库类型必填' }]"
          field="h"
        >
          <a-select
            popup-container="html"
            @change="rowChange($event, 1)"
            class="bacClass"
            @click="inStoCx"
            :style="{ width: '10rem' }"
            v-model="pageData.h"
            allow-search
            allow-clear
          >
            <a-option v-for="item in inStoCxList" :value="item.typeName">
              {{ item.typeName }}
            </a-option>
          </a-select>
        </a-form-item>
        <a-form-item
          label="客户名称"
          :rules="[{ required: true, message: '客户名称必填' }]"
          field="i"
        >
          <a-select
            popup-container="html"
            @change="rowChange($event, 2)"
            @search="customName($event)"
            class="bacClass"
            @click="customName('')"
            :style="{ width: '10rem' }"
            v-model="pageData.i"
            allow-search
            allow-clear
          >
            <a-option v-for="item in customNameCxList" :value="item.brandName">
              {{ item.brandName }}
            </a-option>
          </a-select>
        </a-form-item>
        <a-form-item label="客户订单号">
          <a-input @change="rowChange($event, 3)" class="bacClass" v-model="pageData.j"></a-input>
        </a-form-item>
        <a-form-item
          label="搬运计件"
          :rules="[{ required: true, message: '搬运计件必填' }]"
          field="transportName"
        >
          <a-select
            popup-container="html"
            class="bacClass"
            @focus="focusTransportName"
            @change="rowChange($event, 4)"
            :style="{ width: '10rem' }"
            v-model="pageData.transportName"
            allow-search
            allow-clear
          >
            <a-option
              v-for="(item, index) in pageData.transportNameList"
              :value="item.transportName"
              >{{ item.transportName }}
            </a-option>
          </a-select>
        </a-form-item>
      </a-form>
      <a-space style="margin-bottom: 10px">
        <a-button type="primary" @click="addLine" size="mini">新增</a-button>
      </a-space>
      <AgGridVuesCopys
        :rowHeight="33"
        :headerHeight="33"
        :suppressCopyRowsToClipboard="true"
        :suppressDragLeaveHidesColumns="true"
        rowSelection="multiple"
        @grid-ready="gridReadycg3"
        @columnResized="onColumnResized"
        @columnMoved="onColumnMoved"
        @columnVisible="onColumnVisible"
        style="height: 80%"
        :defaultColDef="defaultColDef"
        class="ag-theme-alpine"
        :rowData="cgData3"
        :columnDefs="cgColumns3"
        :localeText="localeText1"
      ></AgGridVuesCopys>
    </a-drawer>

    <a-modal
      fullscreen
      v-model:visible="visibleYl"
      :on-before-ok="handleOks"
      @cancel="handleCancels"
      :mask-closable="false"
    >
      <template #title> 选择原料入库</template>
      <div class="cgisDatas">
        <div>
          <span>原料编号:</span>
          <a-input class="bacClass" v-model="isLyCodeds" :style="{ width: '150px' }" allow-clear />
        </div>
        <div>
          <span>原料名称:</span>
          <a-input class="bacClass" v-model="isLyNameds" :style="{ width: '150px' }" allow-clear />
        </div>
        <div>
          <a-select popup-container="html" allow-clear class="bacClass" v-model="processType">
            <a-option :value="0">本集团</a-option>
            <a-option :value="1">外加工</a-option>
          </a-select>
        </div>
        <a-button type="primary" @click="cxCgsLists">查询</a-button>
      </div>
      <AgGridVuesCopys
        :rowHeight="33"
        :headerHeight="33"
        :suppressCopyRowsToClipboard="true"
        :suppressDragLeaveHidesColumns="true"
        rowSelection="multiple"
        @grid-ready="gridtableReadycg3"
        @columnResized="onColumnResized"
        @columnMoved="onColumnMoved"
        @columnVisible="onColumnVisible"
        style="height: 70vh; margin-top: 10px"
        :defaultColDef="defaultColDef"
        class="ag-theme-alpine"
        :rowData="wlListXqs"
        :columnDefs="tableColumns3"
        :localeText="localeText1"
      ></AgGridVuesCopys>
      <paginationCopys
        :page-size-options="pagingList1"
        :total="fySelet5.total"
        show-total
        show-jumper
        show-page-size
        @change="PageSize5"
        @page-size-change="change5"
        style="justify-content: center"
        :page-size="fySelet5.size"
        :current="fySelet5.page"
      />
    </a-modal>
    <a-modal
      v-model:visible="cgOut.visible2"
      :on-before-ok="cgHandleOk2"
      @cancel="cadelvs2"
      fullscreen
      :mask-closable="false"
    >
      <template #title> 调拨入库</template>
      <AgGridVuesCopys
        @grid-ready="gridReady6"
        :rowHeight="33"
        :headerHeight="33"
        :suppressCopyRowsToClipboard="true"
        :suppressDragLeaveHidesColumns="true"
        rowSelection="multiple"
        @columnResized="onColumnResized"
        @columnMoved="onColumnMoved"
        @columnVisible="onColumnVisible"
        style="height: 70vh; margin-top: 10px"
        :defaultColDef="defaultColDef"
        class="ag-theme-alpine"
        :rowData="cgData4"
        :columnDefs="cgColumns4"
        :localeText="localeText1"
      ></AgGridVuesCopys>
    </a-modal>
    <a-modal
      v-model:visible="cgOut.visible5"
      :on-before-ok="cgHandleOk5"
      @cancel="cadelvs5"
      fullscreen
      :mask-closable="false"
    >
      <template #title> 退料入库</template>
      <AgGridVuesCopys
        @grid-ready="gridReady7"
        :rowHeight="33"
        :headerHeight="33"
        :suppressCopyRowsToClipboard="true"
        :suppressDragLeaveHidesColumns="true"
        rowSelection="multiple"
        @columnResized="onColumnResized"
        @columnMoved="onColumnMoved"
        @columnVisible="onColumnVisible"
        style="height: 70vh; margin-top: 10px"
        :defaultColDef="defaultColDef"
        class="ag-theme-alpine"
        :rowData="cgData5"
        :columnDefs="cgColumns5"
        :localeText="localeText1"
      ></AgGridVuesCopys>
    </a-modal>
    <!-- 修改原料入库弹窗 -->
    <a-drawer
      ok-text="保存"
      cancel-text="关闭"
      title="修改原料入库"
      :drawer-style="{ zIndex: 999 }"
      :mask-closable="false"
      unmount-on-close
      popup-container=".arco-tabs-content"
      :height="'90%'"
      :visible="editVisible"
      @ok="editDrawerSave"
      placement="bottom"
      @cancel="editDrawerCancel"
    >
      <a-form size="mini" :model="editData" layout="inline">
        <a-form-item label="选择公司" field="firmName">
          <a-input class="bacClass" v-model="editData.firmName" disabled />
        </a-form-item>
        <a-form-item label="仓库" field="warehouseName">
          <a-input class="bacClass" v-model="editData.warehouseName" disabled />
        </a-form-item>
        <a-form-item
          label="入库类型"
          :rules="[{ required: true, message: '入库类型必填' }]"
          field="instockType"
        >
          <a-input class="bacClass" v-model="editData.inStockType" disabled />
        </a-form-item>
        <a-form-item
          label="客户名称"
          :rules="[{ required: true, message: '客户名称必填' }]"
          field="customName"
        >
          <a-input class="bacClass" v-model="editData.customName" disabled />
        </a-form-item>
        <a-form-item label="客户订单号">
          <a-input class="bacClass" v-model="editData.customOrderNo" disabled></a-input>
        </a-form-item>
        <a-form-item label="搬运计件" field="transportName">
          <a-input class="bacClass" v-model="editData.transportName" disabled></a-input>
        </a-form-item>
      </a-form>
      <a-space style="margin-bottom: 10px">
        <a-button type="primary" @click="addLine2" size="mini">新增</a-button>
      </a-space>
      <AgGridVuesCopys
        :rowHeight="33"
        :headerHeight="33"
        :suppressCopyRowsToClipboard="true"
        :suppressDragLeaveHidesColumns="true"
        rowSelection="multiple"
        @grid-ready="gridReadycg4"
        @columnResized="onColumnResized"
        @columnMoved="onColumnMoved"
        @columnVisible="onColumnVisible"
        style="height: 80%"
        :defaultColDef="defaultColDef"
        class="ag-theme-alpine"
        :columnDefs="cgColumns6"
        :localeText="localeText1"
      ></AgGridVuesCopys>
    </a-drawer>
  </pageTabelLayout>
</template>
<script setup lang="ts">
  import { ref, reactive, watch } from 'vue'
  import { post, get } from '@/api/http'
  import { localeText } from '@/api/aggridZw'
  
  import Toolbar from '@/components/Toolbar.vue'
  import { Message, Modal } from '@arco-design/web-vue'
  import { ElMessage } from 'element-plus'
  import WHService from '@/service/wh'
  import CorporateSectorCascader from '@/components/corporateSectorCascader/inde.vue'
  import dayjs from 'dayjs'
  import usePermission from '@/store/modules/permission'
  import { pagingList } from '@/api/paging'
  import { saveOrUpdateGridState as saveOrUpdateGridState01 } from '@/hooks/useGridState'
  import { saveOrUpdateGridState as saveOrUpdateGridState02 } from '@/hooks/useGridState'
  import { saveOrUpdateGridState as saveOrUpdateGridState03 } from '@/hooks/useGridState'
  import { saveOrUpdateGridState as saveOrUpdateGridState04 } from '@/hooks/useGridState'
  import { saveOrUpdateGridState as saveOrUpdateGridState05 } from '@/hooks/useGridState'
  import ButtionRender1 from '@/components/aggridCellRenDerer/buttionRender1.vue'
  import setTableTotalRow from '@/utils/setTableTotalRow.ts'
  import emitter from '@/hooks/useEventBus'
  const pagingList1: any = ref(pagingList)
  const permissionStore = usePermission()

  const toolbarList: any = ref([
    `${permissionStore.hasPermisson('ylrk.rkdglcx') ? '查询' : ''}`,
    `${permissionStore.hasPermisson('ylrk.xzrlrk') ? '新增原料入库' : ''}`,
    `${permissionStore.hasPermisson('ylrk.sh') ? '审核' : ''}`,
    `${permissionStore.hasPermisson('ylrk.sc') ? '删除' : ''}`,
    `${permissionStore.hasPermisson('ylrk.yscrkqxsh') ? '取消审核' : ''}`,
  ])
  const addType = ref('')
  const visibleYl = ref(false)

  const fySelet2: any = reactive({
    total: 10,
    size: 10,
    page: 1,
  })

  const PageSize2 = (val: any) => {
    fySelet2.page = val
    cxYcList()
  }

  const change2 = (val: any) => {
    fySelet2.size = val
    cxYcList()
  }

  const fySelet3: any = reactive({
    total: 10,
    size: 10,
    page: 1,
  })

  const PageSize3 = (val: any) => {
    fySelet3.page = val
    cxDbsList()
  }

  const change3 = (val: any) => {
    fySelet3.size = val
    cxDbsList()
  }

  const headerShow = ref(true)

  const pageData: any = reactive({
    a: '',
    b: '',
    c: '',
    d: '',
    e: null,
    f: null,
    g: null,
    h: null,
    yarnCode: '',
    yarnName: '',
    yarnBrand: '',
    productionBatch: '',
    level: '',
    orderType: null,
    prodCode: '',
    khName: '',
    dropDownTime: [dayjs().format('YYYY-MM-DD'), dayjs().format('YYYY-MM-DD')],
    dropDownTime1: [dayjs().format('YYYY-MM-DD'), dayjs().format('YYYY-MM-DD')],
    transportNameList: [],
    transportName: '',
    materialReturnCode: '',
    audit_state: null,
    sourceNumber: '', //来源单号
    inStockTypes:[],
    inStockList:[],
  })

  const tableDataList = ref([])
  let oneDayTime: any = ref([dayjs().format('YYYY-MM-DD'), dayjs().format('YYYY-MM-DD')])
  const tableDataList3 = ref([])

  const gridOption = ref()
  const colState = ref()
  const gridReady = (params: any) => {
    gridOption.value = params.api
    colState.value = params.columnApi
  }
  const gridOption6 = ref()
  const gridReady6 = (params: any) => {
    gridOption6.value = params.api
  }
  const gridOption7 = ref()
  const gridReady7 = (params: any) => {
    gridOption7.value = params.api
  }
  const gridOptioncg3 = ref()
  const gridReadycg3 = (params: any) => {
    gridOptioncg3.value = params.api
  }
  const gridOptioncg4 = ref()
  const gridReadycg4 = (params: any) => {
    gridOptioncg4.value = params.api
  }
  const gridtableOptioncg3 = ref()
  const gridtableReadycg3 = (params: any) => {
    gridtableOptioncg3.value = params.api
  }
  const cgColumns2Option = ref()
  const cgColumns2Ready = (params: any) => {
    cgColumns2Option.value = params.api
  }
  const gridOption3 = ref()
  const colState3 = ref()
  const gridReady3 = (params: any) => {
    gridOption3.value = params.api
    colState3.value = params.columnApi
  }

  const defaultColDef = {
    sortable: true,
    resizable: true,
    filter: true,
  }

  const defaultColDef3 = {
    sortable: true,
    resizable: true,
    filter: true,
  }

  const localeText1: any = ref(localeText)

  const tc = [
    {
      showRowGroup: 'hide_def',
      field: 'ckBox',
      headerName: '',
      checkboxSelection: true,
      headerCheckboxSelection: true,
      pinned: 'left',
      width: 100,
      resizable: false,
      filter: false,
      sortable: false,
      minWidth: 50,
      maxWidth: 150,
      lockPosition: 'left',
    },
    {
      headerName: '入库单号',
      field: 'inStockNumber',
      width: 150,
    },
    {
      headerName: '收货单号',
      field: 'receiptNumber',
      // pinned: o['fixed'],
      width: 150,
    },
    {
      headerName: '采购单号',
      field: 'purchaseCode',
      width: 150,
    },
    {
      headerName: '来源单号',
      field: 'sourceNumber',
      width: 150,
    },
    {
      headerName: '客户单号',
      field: 'customOrderNo',
      width: 150,
    },
    {
      headerName: '公司',
      field: 'firm',
      width: 150,
    },
    {
      headerName: '仓库名称',
      field: 'warehouse',
      width: 150,
    },
    {
      headerName: '入库类型',
      field: 'inStockType',
      width: 150,
    },
    {
      headerName: '搬运计件',
      field: 'transportName',
      width: 150,
    },
    {
      headerName: '供应商名称',
      field: 'supplier',
      width: 150,
    },
    {
      headerName: '客户名称',
      field: 'customName',
      width: 150,
    },
    {
      headerName: '原料编号',
      field: 'yarnCode',
      width: 150,
    },
    {
      headerName: '原料名称',
      field: 'yarnName',
      width: 150,
    },
    {
      headerName: '纱牌',
      field: 'yarnBrand',
      width: 150,
    },
    {
      headerName: '纱批',
      field: 'productionBatch',
      width: 150,
    },
    {
      headerName: '等级',
      field: 'level',
      width: 150,
    },
    // {
    //     headerName: '可配色称',
    //     field: 'matchColor',
    //     width: 150
    // },
    {
      headerName: '色号',
      field: 'colorCode',
      width: 150,
    },
    {
      headerName: '色称',
      field: 'colorName',
      width: 150,
    },
    {
      headerName: '整件/个数',
      field: 'pieceCount',
      width: 150,
    },
    {
      headerName: '整件/件数',
      field: 'pieceNumber',
      width: 150,
    },
    {
      headerName: '整件/件重',
      field: 'pieceWeight',
      width: 150,
    },
    {
      headerName: '散件/个数',
      field: 'bulkCount',
      width: 150,
    },
    {
      headerName: '散件/件数',
      field: 'bulkNumber',
      width: 150,
    },
    {
      headerName: '散件/散重',
      field: 'bulkWeight',
      width: 150,
    },
    {
      headerName: '总数量',
      field: 'weightTotal',
      width: 150,
    },
    {
      headerName: '包装',
      field: 'packing',
      width: 150,
    },
    {
      headerName: '包装特征',
      field: 'packingFeature',
      width: 150,
    },
    {
      headerName: '纸骨',
      field: 'paperBone',
      width: 150,
    },
    {
      headerName: '单位',
      field: 'unit',
      width: 150,
    },
    {
      headerName: '库位',
      field: 'location',
      width: 150,
    },
    {
      headerName: '备注',
      field: 'remark',
      width: 150,
    },
    {
      headerName: '开单人',
      field: 'createName',
      width: 150,
    },
    {
      headerName: '开单日期',
      field: 'createDate',
      width: 150,
    },
    {
      headerName: '操作',
      field: 'action',
      pinned: 'right',
      width: 150,
      cellRenderer: ButtionRender1,
      cellRendererParams: (params: any) => {
        return {
          buttonList: [
            {
              type:
                (params.data.inStockType == '其他入库' || params.data.inStockType == '客供入库') &&
                params.data.auditState == 0
                  ? 'primary'
                  : 'info',
              text: '修改',
              show: true,
              disabled:
                (params.data.inStockType == '其他入库' || params.data.inStockType == '客供入库') &&
                params.data.auditState == 0
                  ? false
                  : true,
              typeName: 'el-button',
              Callback: (data: any) => {
                return {
                  rowData: data,
                  emitString: 'ReceiptList3-EditHandle',
                }
              },
            },
          ],
          eltagSize: 0,
        }
      },
      cellStyle: (params: any) => {
        if (params.node.rowPinned == 'bottom') return { display: 'none' }
      },
      filterParams: {
        valueFormatter: function (params: any) {
          return params.value == '0' ? '未审核' : params.value == '1' ? '已审核入库' : ''
        },
      },
    },
    {
      headerName: '审核状态',
      field: 'auditState',
      pinned: 'right',
      width: 150,
      cellRenderer: {
        template: `
        <a-button v-if="states == 1" status="success">已审核入库</a-button>
        <a-button v-else="states == 0" type="dashed" status="success">未审核</a-button>
      `,
        setup(props: any) {
          return {
            states: props.params.data.auditState,
          }
        },
      },
      cellStyle: (params: any) => {
        if (params.node.rowPinned == 'bottom') return { display: 'none' }
      },
      filterParams: {
        valueFormatter: function (params: any) {
          return params.value == '0' ? '未审核' : params.value == '1' ? '已审核入库' : ''
        },
      },
    },
    {
      headerName: '审核人员',
      field: 'auditName',
      width: 150,
    },
    {
      headerName: '生产日期开始',
      field: 'productionDateStart',
      width: 170,
    },
    {
      headerName: '生产日期结束',
      field: 'productionDateEnd',
      width: 170,
    },
    {
      headerName: '审核日期',
      field: 'auditDate',
      width: 150,
    },
  ]

  const tc3 = [
    {
      showRowGroup: 'hide_def',
      headerName: '',
      checkboxSelection: true,
      headerCheckboxSelection: true,
      pinned: 'left',
      width: 50,
      resizable: false,
      filter: false,
      sortable: false,
      minWidth: 50,
      maxWidth: 50,
      lockPosition: 'left',
    },
    {
      headerName: '收货单号',
      field: 'receiptNumber',
      // pinned: o['fixed'],
      width: 150,
    },
    {
      headerName: '收货日期',
      field: 'receiptDate',
      // pinned: o['fixed'],
      width: 150,
    },
    {
      headerName: '收货类型',
      field: 'receiptType',
      width: 150,
    },
    {
      headerName: '收货仓库',
      field: 'warehouse',
      width: 150,
    },
    {
      headerName: '公司',
      field: 'firm',
      width: 150,
    },
    {
      headerName: '供应商',
      field: 'supplier',
      width: 150,
    },
    {
      headerName: '贸易商',
      field: 'trader',
      width: 150,
    },
    {
      headerName: '库存组织',
      field: 'inventoryOrganization',
      width: 150,
    },
    {
      headerName: '货主单位',
      field: 'ownerUnit',
      width: 150,
    },
    {
      headerName: '采购单号',
      field: 'purchaseCode',
      width: 150,
    },
    {
      headerName: '订单编号',
      field: 'orderNumber',
      width: 150,
    },
    {
      headerName: '纱线编号',
      field: 'yarnCode',
      width: 150,
    },
    {
      headerName: '纱线名称',
      field: 'yarnName',
      width: 150,
    },
    {
      headerName: '纱牌',
      field: 'yarnBrand',
      width: 150,
    },
    {
      headerName: '等级',
      field: 'level',
      width: 150,
    },
    // {
    //     headerName: '可配色称',
    //     field: 'matchColor',
    //     width: 150
    // },
    {
      headerName: '色号',
      field: 'colorCode',
      width: 150,
    },
    {
      headerName: '色称',
      field: 'colorName',
      width: 150,
    },
    {
      headerName: '生产日期',
      field: 'productionDateStr',
      width: 150,
    },
    {
      headerName: '生产日期开始',
      field: 'productionDateStart',
      width: 150,
    },
    {
      headerName: '生产日期结束',
      field: 'productionDateEnd',
      width: 150,
    },
    {
      headerName: '供应商批号',
      field: 'supplierBatch',
      width: 150,
    },
    {
      headerName: '生产批号',
      field: 'productionBatch',
      width: 150,
    },
    {
      headerName: '纸骨',
      field: 'paperBone',
      width: 150,
    },
    {
      headerName: '包装特征',
      field: 'packingFeature',
      width: 150,
    },
    {
      headerName: '包装',
      field: 'packing',
      width: 150,
    },
    {
      headerName: '纱线整件数量',
      field: 'pieceNumber',
      width: 150,
    },
    {
      headerName: '纱线整件重量',
      field: 'pieceWeight',
      width: 150,
    },
    {
      headerName: '纱线散件数量',
      field: 'bulkNumber',
      width: 150,
    },
    {
      headerName: '纱线散件重量',
      field: 'bulkWeight',
      width: 150,
    },
    {
      headerName: '只数',
      field: 'onlyCount',
      width: 150,
    },
    {
      headerName: '整件重量',
      field: 'pieceWeightTotal',
      width: 150,
    },
    {
      headerName: '采购单价',
      field: 'price',
      width: 150,
    },
    {
      headerName: '含税单价',
      field: 'taxPrice',
      width: 150,
    },
    {
      headerName: '不含税单价',
      field: 'notPrice',
      width: 150,
    },
    {
      headerName: '合计重量',
      field: 'weightTotal',
      width: 150,
    },
    {
      headerName: '单位',
      field: 'unit',
      width: 150,
    },
    {
      headerName: '规格',
      field: 'spec',
      width: 150,
    },
    {
      headerName: '经手人',
      field: 'orderCreateName',
      width: 150,
    },
    {
      headerName: '是否试纱',
      field: 'testYarnState',
      width: 150,
      cellRenderer: {
        template: `<span>{{ states == 0 ? '否' : states == 1 ? '是' : '' }}</span>`,
        setup(props: any) {
          return {
            states: props.params.data.testYarnState,
          }
        },
      },
      filterParams: {
        valueFormatter: function (params: any) {
          return params.value == '0' ? '否' : params.value == '1' ? '是' : ''
        },
      },
    },
    {
      headerName: '是否检测',
      field: 'detectionState',
      width: 150,
      cellRenderer: {
        template: `<span>{{ states == 0 ? '否' : states == 1 ? '是' : '' }}</span>`,
        setup(props: any) {
          return {
            states: props.params.data.detectionState,
          }
        },
      },
      filterParams: {
        valueFormatter: function (params: any) {
          return params.value == '0' ? '否' : params.value == '1' ? '是' : ''
        },
      },
    },
    {
      headerName: '收货状态',
      field: 'receiveState',
      width: 150,
      cellRenderer: {
        template: `<span>{{ states == 0 ? '否' : states == 1 ? '是' : '' }}</span>`,
        setup(props: any) {
          return {
            states: props.params.data.receiveState,
          }
        },
      },
      filterParams: {
        valueFormatter: function (params: any) {
          return params.value == '0' ? '否' : params.value == '1' ? '是' : ''
        },
      },
    },
    {
      headerName: '收货人',
      field: 'receiveName',
      width: 150,
    },
    {
      headerName: '实际收货时间',
      field: 'receiveDate',
      width: 150,
    },
    {
      headerName: '备注',
      field: 'remark',
      width: 150,
    },
    {
      headerName: '操作',
      field: 'atous',
      pinned: 'right',
      filter: false,
      width: 120,
      cellRenderer: {
        template: `
        <a-space>
          <a-button v-if="e" @click="a" type="primary">入库</a-button>
        </a-space>
      `,
        setup(props: any) {
          const a = () => {
            rouWh(props.params.data)
          }
          return {
            a,
            e: permissionStore.hasPermisson('ylrk.cgshdclrk'),
          }
        },
      },
      cellStyle: (params: any) => {
        if (params.node.rowPinned == 'bottom') return { display: 'none' }
      },
    },
  ]

  const tc5 = [
    {
      showRowGroup: 'hide_def',
      headerName: '',
      checkboxSelection: true,
      headerCheckboxSelection: true,
      pinned: 'left',
      width: 50,
      resizable: false,
      filter: false,
      sortable: false,
      minWidth: 50,
      maxWidth: 50,
      lockPosition: 'left',
    },
    {
      headerName: '公司',
      field: 'firm',
      width: 150,
    },
    {
      headerName: '退料单号',
      field: 'sourceNumber',
      width: 150,
    },
    {
      headerName: '织布单号',
      field: 'planOrderCode',
      width: 150,
    },
    {
      headerName: '客户',
      field: 'customName',
      width: 150,
    },
    {
      headerName: '原料编号',
      field: 'yarnCode',
      width: 150,
    },
    {
      headerName: '原料名称',
      field: 'yarnName',
      width: 150,
    },
    {
      headerName: '纱牌',
      field: 'yarnBrand',
      width: 150,
    },
    {
      headerName: '纱批',
      field: 'productionBatch',
      width: 150,
    },
    {
      headerName: '色号',
      field: 'colorCode',
      width: 150,
    },
    {
      headerName: '色称',
      field: 'colorName',
      width: 150,
    },
    {
      headerName: '等级',
      field: 'level',
      width: 150,
    },
    {
      headerName: '整件/个数',
      field: 'pieceCount',
      width: 150,
    },
    {
      headerName: '整件/件数',
      field: 'pieceNumber',
      width: 150,
    },
    {
      headerName: '整件/件重',
      field: 'pieceWeight',
      width: 150,
    },
    {
      headerName: '散件/个数',
      field: 'bulkCount',
      width: 150,
    },
    {
      headerName: '散件/件数',
      field: 'bulkNumber',
      width: 150,
    },
    {
      headerName: '散件/散重',
      field: 'bulkWeight',
      width: 150,
    },
    {
      headerName: '退料数量',
      field: 'weightTotal',
      width: 150,
    },

    {
      headerName: '库存-整件/件数',
      field: 'stockPieceNum',
      width: 150,
    },
    {
      headerName: '库存-散件/个数',
      field: 'stockBulkCount',
      width: 150,
    },
    {
      headerName: '库存-散件/件数',
      field: 'stockBulkNum',
      width: 150,
    },
    {
      headerName: '库存-散件/散重',
      field: 'stockBulkWeight',
      width: 150,
    },
    {
      headerName: '创建时间',
      field: 'createTime',
      width: 150,
    },
    {
      headerName: '创建人',
      field: 'createName',
      width: 150,
    },
    {
      headerName: '入库状态',
      field: 'stockInState',
      pinned: 'right',
      width: 150,
      cellRenderer: {
        template: `
        <a-button v-if="states == 1" status="success">已入库</a-button>
        <a-button v-else="states == 0" type="dashed" status="success">未入库</a-button>
      `,
        setup(props: any) {
          return {
            states: props.params.data.stockInState,
          }
        },
      },
      cellStyle: (params: any) => {
        if (params.node.rowPinned == 'bottom') return { display: 'none' }
      },
      filterParams: {
        valueFormatter: function (params: any) {
          return params.value == '0' ? '未入库' : params.value == '1' ? '已入库' : ''
        },
      },
    },
  ]
  const cgColumns5: any = [
    {
      dataIndex: 'firm',
      headerName: '公司',
      field: 'firm',
      width: 150,
      // cellRenderer: {
      //   template: `
      //   <a-input class="bacClass" v-model="record.firm"></a-input>
      //   `,
      //   setup(props: any) {
      //     const record = ref()
      //     record.value = props.params.data
      //     return {
      //       record,

      //     }
      //   },
      // },
    },
    {
      dataIndex: 'sourceNumber',
      headerName: '退料单号',
      field: 'sourceNumber',
      width: 150,
      // cellRenderer: {
      //   template: `
      //   <a-input class="bacClass" v-model="record.sourceNumber"></a-input>
      //   `,
      //   setup(props: any) {
      //     const record = ref()
      //     record.value = props.params.data
      //     return {
      //       record,

      //     }
      //   },
      // },
    },
    {
      dataIndex: 'planOrderCode',
      headerName: '织布单号',
      field: 'planOrderCode',
      width: 150,
      // cellRenderer: {
      //   template: `
      //   <a-input class="bacClass" v-model="record.planOrderCode"></a-input>
      //   `,
      //   setup(props: any) {
      //     const record = ref()
      //     record.value = props.params.data
      //     return {
      //       record,

      //     }
      //   },
      // },
    },
    {
      dataIndex: 'customName',
      headerName: '客户',
      field: 'customName',
      width: 150,
      // cellRenderer: {
      //   template: `
      //   <a-input class="bacClass" v-model="record.customName"></a-input>
      //   `,
      //   setup(props: any) {
      //     const record = ref()
      //     record.value = props.params.data
      //     return {
      //       record,

      //     }
      //   },
      // },
    },
    {
      dataIndex: 'yarnCode',
      headerName: '原料编号',
      field: 'yarnCode',
      width: 150,
      // cellRenderer: {
      //   template: `
      //   <a-input class="bacClass" v-model="record.yarnCode"></a-input>
      //   `,
      //   setup(props: any) {
      //     const record = ref()
      //     record.value = props.params.data
      //     return {
      //       record,

      //     }
      //   },
      // },
    },
    {
      dataIndex: 'yarnName',
      headerName: '原料名称',
      field: 'yarnName',
      width: 150,
      // cellRenderer: {
      //   template: `
      //   <a-input class="bacClass" v-model="record.yarnName"></a-input>
      //   `,
      //   setup(props: any) {
      //     const record = ref()
      //     record.value = props.params.data
      //     return {
      //       record,

      //     }
      //   },
      // },
    },
    {
      dataIndex: 'yarnBrand',
      headerName: '纱牌',
      field: 'yarnBrand',
      width: 150,
      // cellRenderer: {
      //   template: `
      //   <a-input class="bacClass" v-model="record.yarnBrand"></a-input>
      //   `,
      //   setup(props: any) {
      //     const record = ref()
      //     record.value = props.params.data
      //     return {
      //       record,

      //     }
      //   },
      // },
    },
    {
      dataIndex: 'productionBatch',
      headerName: '纱批',
      field: 'productionBatch',
      width: 150,
      // cellRenderer: {
      //   template: `
      //   <a-input class="bacClass" v-model="record.productionBatch"></a-input>
      //   `,
      //   setup(props: any) {
      //     const record = ref()
      //     record.value = props.params.data
      //     return {
      //       record,

      //     }
      //   },
      // },
    },
    {
      dataIndex: 'colorCode',
      headerName: '色号',
      field: 'colorCode',
      width: 150,
      // cellRenderer: {
      //   template: `
      //   <a-input class="bacClass" v-model="record.colorCode"></a-input>
      //   `,
      //   setup(props: any) {
      //     const record = ref()
      //     record.value = props.params.data
      //     return {
      //       record,

      //     }
      //   },
      // },
    },
    {
      dataIndex: 'colorName',
      headerName: '色称',
      field: 'colorName',
      width: 150,
      // cellRenderer: {
      //   template: `
      //   <a-input class="bacClass" v-model="record.colorName"></a-input>
      //   `,
      //   setup(props: any) {
      //     const record = ref()
      //     record.value = props.params.data
      //     return {
      //       record,

      //     }
      //   },
      // },
    },
    {
      dataIndex: 'level',
      headerName: '等级',
      field: 'level',
      width: 150,
      // cellRenderer: {
      //   template: `
      //   <a-input class="bacClass" v-model="record.level"></a-input>
      //   `,
      //   setup(props: any) {
      //     const record = ref()
      //     record.value = props.params.data
      //     return {
      //       record,

      //     }
      //   },
      // },
    },
    {
      dataIndex: 'pieceCount1',
      headerName: '整件/个数',
      field: 'pieceCount1',
      width: 150,
      // cellRenderer: {
      //   template: `
      //   <a-input class="bacClass" v-model="record.pieceCount1"></a-input>
      //   `,
      //   setup(props: any) {
      //     const record = ref()
      //     record.value = props.params.data
      //     return {
      //       record,

      //     }
      //   },
      // },
    },
    {
      dataIndex: 'pieceNumber1',
      headerName: '整件/件数',
      field: 'pieceNumber1',
      width: 150,
      // cellRenderer: {
      //   template: `
      //   <a-input class="bacClass" v-model="record.pieceNumber1"></a-input>
      //   `,
      //   setup(props: any) {
      //     const record = ref()
      //     record.value = props.params.data
      //     return {
      //       record,

      //     }
      //   },
      // },
    },
    {
      dataIndex: 'pieceWeight1',
      headerName: '整件/件重',
      field: 'pieceWeight1',
      width: 150,
      // cellRenderer: {
      //   template: `
      //   <a-input class="bacClass" v-model="record.pieceWeight1"></a-input>
      //   `,
      //   setup(props: any) {
      //     const record = ref()
      //     record.value = props.params.data
      //     return {
      //       record,

      //     }
      //   },
      // },
    },
    {
      dataIndex: 'bulkCount1',
      headerName: '散件/个数',
      field: 'bulkCount1',
      width: 150,
      // cellRenderer: {
      //   template: `
      //   <a-input class="bacClass" v-model="record.bulkCount1"></a-input>
      //   `,
      //   setup(props: any) {
      //     const record = ref()
      //     record.value = props.params.data
      //     return {
      //       record,

      //     }
      //   },
      // },
    },
    {
      dataIndex: 'bulkNumber1',
      headerName: '散件/件数',
      field: 'bulkNumber1',
      width: 150,
      // cellRenderer: {
      //   template: `
      //   <a-input class="bacClass" v-model="record.bulkNumber1"></a-input>
      //   `,
      //   setup(props: any) {
      //     const record = ref()
      //     record.value = props.params.data
      //     return {
      //       record,

      //     }
      //   },
      // },
    },
    {
      dataIndex: 'bulkWeight1',
      headerName: '散件/散重',
      field: 'bulkWeight1',
      width: 150,
      // cellRenderer: {
      //   template: `
      //   <a-input class="bacClass" v-model="record.bulkWeight1"></a-input>
      //   `,
      //   setup(props: any) {
      //     const record = ref()
      //     record.value = props.params.data
      //     return {
      //       record,

      //     }
      //   },
      // },
    },
    {
      dataIndex: 'weightTotal1',
      headerName: '退料数量',
      field: 'weightTotal1',
      width: 150,
      // cellRenderer: {
      //   template: `
      //   <a-input class="bacClass" v-model="record.weightTotal1"></a-input>
      //   `,
      //   setup(props: any) {
      //     const record = ref()
      //     record.value = props.params.data
      //     return {
      //       record,

      //     }
      //   },
      // },
    },

    {
      dataIndex: 'stockPieceNum',
      headerName: '库存-整件/件数',
      field: 'stockPieceNum',
      width: 150,
      // cellRenderer: {
      //   template: `
      //   <a-input class="bacClass" v-model="record.stockPieceNum"></a-input>
      //   `,
      //   setup(props: any) {
      //     const record = ref()
      //     record.value = props.params.data
      //     return {
      //       record,

      //     }
      //   },
      // },
    },
    {
      dataIndex: 'stockBulkCount',
      headerName: '库存-散件/个数',
      field: 'stockBulkCount',
      width: 150,
      // cellRenderer: {
      //   template: `
      //   <a-input class="bacClass" v-model="record.stockBulkCount"></a-input>
      //   `,
      //   setup(props: any) {
      //     const record = ref()
      //     record.value = props.params.data
      //     return {
      //       record,

      //     }
      //   },
      // },
    },
    {
      dataIndex: 'stockBulkNum',
      headerName: '库存-散件/件数',
      field: 'stockBulkNum',
      width: 150,
      // cellRenderer: {
      //   template: `
      //   <a-input class="bacClass" v-model="record.stockBulkNum"></a-input>
      //   `,
      //   setup(props: any) {
      //     const record = ref()
      //     record.value = props.params.data
      //     return {
      //       record,

      //     }
      //   },
      // },
    },
    {
      dataIndex: 'stockBulkWeight',
      headerName: '库存-散件/散重',
      field: 'stockBulkWeight',
      width: 150,
      // cellRenderer: {
      //   template: `
      //   <a-input class="bacClass" v-model="record.stockBulkWeight"></a-input>
      //   `,
      //   setup(props: any) {
      //     const record = ref()
      //     record.value = props.params.data
      //     return {
      //       record,

      //     }
      //   },
      // },
    },
    {
      dataIndex: 'warehousePieceNum',
      field: 'warehousePieceNum',
      headerName: '已入库-整件件数',
      width: 150,
      // cellRenderer: {
      //   template: `
      //   <a-input class="bacClass" v-model="record.warehousePieceNum"></a-input>
      //   `,
      //   setup(props: any) {
      //     const record = ref()
      //     record.value = props.params.data
      //     return {
      //       record,

      //     }
      //   },
      // },
    },
    {
      dataIndex: 'warehouseBulkWeight',
      field: 'warehouseBulkWeight',
      headerName: '已入库-散件重量',
      width: 150,
      // cellRenderer: {
      //   template: `
      //   <a-input class="bacClass" v-model="record.warehouseBulkWeight"></a-input>
      //      `,
      //   setup(props: any) {
      //     const record = ref()
      //     record.value = props.params.data
      //     return {
      //       record,

      //     }
      //   },
      // },
    },
    {
      dataIndex: 'warehouseBulkNum',
      field: 'warehouseBulkNum',
      headerName: '已入库-散件件数',
      width: 150,
      // cellRenderer: {
      //   template: `
      //   <a-input class="bacClass" v-model="record.warehouseBulkNum"></a-input>
      //      `,
      //   setup(props: any) {
      //     const record = ref()
      //     record.value = props.params.data
      //     return {
      //       record,

      //     }
      //   },
      // },
    },
    {
      dataIndex: 'warehouseBulkCount',
      field: 'warehouseBulkCount',
      headerName: '已入库-散件个数',
      width: 150,
      // cellRenderer: {
      //   template: `
      //   <a-input class="bacClass" v-model="record.warehouseBulkCount"></a-input>
      //      `,
      //   setup(props: any) {
      //     const record = ref()
      //     record.value = props.params.data
      //     return {
      //       record,

      //     }
      //   },
      // },
    },
    {
      dataIndex: 'warehouseReturnNum',
      field: 'warehouseReturnNum',
      headerName: '已入库-退料数量',
      width: 150,
      // cellRenderer: {
      //   template: `
      //   <a-input class="bacClass" v-model="record.warehouseReturnNum"></a-input>
      //      `,
      //   setup(props: any) {
      //     const record = ref()
      //     record.value = props.params.data
      //     return {
      //       record,

      //     }
      //   },
      // },
    },

    {
      dataIndex: 'pieceNumber',
      field: 'pieceNumber',
      slotName: 'pieceNumber',
      headerName: '入库整件件数',
      pinned: 'right',
      width: 150,
      fixed: 'right',
      cellRenderer: {
        template: `
        <a-input-number @change="changeEvent" class="bacClass" :min="0"
                        v-model="record.pieceNumber"></a-input-number>         `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const changeEvent = () => {
            cahngesCount7(record)
          }
          return {
            record,
            changeEvent,
          }
        },
      },
    },
    // {
    //     dataIndex: 'pieceCount',
    //     field: 'pieceCount',
    //     slotName: 'pieceCount',
    //     headerName: '入库整件个数',
    //     width: 150,
    //     fixed: 'right',
    // },
    // {
    //     dataIndex: 'pieceWeight',
    //     field: 'pieceWeight',
    //     slotName: 'pieceWeight',
    //     headerName: '入库整件件重',
    //     width: 150,
    //     fixed: 'right',
    // },

    {
      dataIndex: 'bulkNumber',
      field: 'bulkNumber',
      slotName: 'bulkNumber',
      headerName: '入库散件件数',
      pinned: 'right',
      width: 150,
      fixed: 'right',
      cellRenderer: {
        template: `
        <a-input-number class="bacClass" v-model="record.bulkNumber" :min="0"></a-input-number>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          return {
            record,
          }
        },
      },
    },
    {
      dataIndex: 'bulkCount',
      field: 'bulkCount',
      slotName: 'bulkCount',
      headerName: '入库散件个数',
      pinned: 'right',
      width: 150,
      fixed: 'right',
      cellRenderer: {
        template: `
        <a-input-number class="bacClass" v-model="record.bulkCount" :min="0"></a-input-number>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          return {
            record,
          }
        },
      },
    },
    {
      dataIndex: 'bulkWeight',
      field: 'bulkWeight',
      slotName: 'bulkWeight',
      headerName: '入库散件重量',
      pinned: 'right',
      width: 150,
      fixed: 'right',
      cellRenderer: {
        template: `
        <a-input-number @change="changeEvent" class="bacClass" v-model="record.bulkWeight"
                        :min="0"></a-input-number>         `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const changeEvent = () => {
            cahngesCount7(record)
          }
          return {
            record,
            changeEvent,
          }
        },
      },
    },
    {
      dataIndex: 'weightTotal',
      field: 'weightTotal',
      pinned: 'right',
      // slotName: 'weightTotal',
      headerName: '入库总重量',
      width: 150,
      fixed: 'right',
      // cellRenderer: {
      //   template: `
      //   <a-input-number class="bacClass" v-model="record.weightTotal" disabled></a-input-number>
      //      `,
      //   setup(props: any) {
      //     const record = ref()
      //     record.value = props.params.data
      //     return {
      //       record,

      //     }
      //   },
      // },
    },
    {
      dataIndex: 'remark',
      field: 'remark',
      headerName: '备注 ',
      slotName: 'remark',
      width: 150,
      cellRenderer: {
        template: `
        <a-input class="bacClass" v-model="record.remark"></a-input>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          return {
            record,
          }
        },
      },
    },
  ]
  const selectHandler = () => {
    if (tabsKeys.value == 1) {
      fySelet2.page = 1
      cxYcList()
    } else if (tabsKeys.value == 2) {
      fySelet3.page = 1
      cxDbsList()
    } else if (tabsKeys.value == 3) {
      fySelet.page = 1
      cxCgsList()
    } else if (tabsKeys.value == 4) {
      fySelet4.page = 1
      cxCgsList2()
    } else if (tabsKeys.value == 5) {
      fySelet6.page = 1
      cjOutIntSelect()
    }
  }
  const editData = reactive({
    firmName: '',
    firmId: '',
    warehouseName: '',
    warehouseId: '',
    inStockType: '',
    customName: '',
    customOrderNo: '',
    transportName: '',
    inStockNumber: '',
  })
  const editVisible = ref<boolean>(false)
  const editDrawerSave = async () => {
    try {
      const allRowsData: any[] = []
      gridOptioncg4.value.forEachNode((node: any) => {
        allRowsData.push(node.data)
      })
      allRowsData.forEach((item: any) => {
        if (item.auditState != 0) {
          item.auditState = 0
        }
      })
      for (let i = 0; i < allRowsData.length; i++) {
        if (
          allRowsData[i].weightTotal == '' ||
          allRowsData[i].weightTotal == undefined ||
          allRowsData[i].weightTotal == null ||
          allRowsData[i].weightTotal == 0
        ) {
          Message.error('总数量必须大于0')
          return false
        }
        if (
          allRowsData[i].inStockType == '' ||
          allRowsData[i].inStockType == undefined ||
          allRowsData[i].inStockType == null
        ) {
          Message.error('入库类型必填')
          return false
        }
        if (allRowsData[i]['pieceNumber'] > 0) {
          if (
            allRowsData[i]['pieceCount'] == '' ||
            allRowsData[i]['pieceCount'] == undefined ||
            allRowsData[i]['pieceCount'] == null ||
            allRowsData[i]['pieceCount'] == 0
          ) {
            Message.error('请录入整件个数!')
            return false
          }
        }
        if (
          allRowsData[i].yarnBrand == '' ||
          allRowsData[i].yarnBrand == undefined ||
          allRowsData[i].yarnBrand == null
        ) {
          Modal.confirm({
            title: '系统提示',
            content: '纱牌未填确认修改?',
            onOk: async () => {
              const updateData = [...deletedInitData.value, ...allRowsData]
              const paramsArr = updateData.map((item: any) => {
                if (!item.id) {
                  return {
                    id: '',
                    firm: editData.firmName,
                    firmId: editData.firmId,
                    warehouse: editData.warehouseName,
                    warehouseId: editData.warehouseId,
                    inStockType: editData.inStockType,
                    customName: editData.customName,
                    customOrderNo: editData.customOrderNo,
                    transportName: editData.transportName,
                    inStockNumber: editData.inStockNumber,
                    ...item,
                  }
                }
                return item
              })
              console.log('paramsArr', paramsArr)
              const res = await post({
                url: 'wms/yarnInStock/updateInfo',
                data: paramsArr,
              })
              if (res.code == 200) {
                cxYcList()
                console.log('res', res)
                Message.success('修改成功')
                editVisible.value = false
                resetEditData()
              } else {
                Message.error(res.message)
              }
            },
          })
          return false
        }
      }
      const updateData = [...deletedInitData.value, ...allRowsData]
      const paramsArr = updateData.map((item: any) => {
        if (!item.id) {
          return {
            id: '',
            firm: editData.firmName,
            firmId: editData.firmId,
            warehouse: editData.warehouseName,
            warehouseId: editData.warehouseId,
            inStockType: editData.inStockType,
            customName: editData.customName,
            customOrderNo: editData.customOrderNo,
            transportName: editData.transportName,
            inStockNumber: editData.inStockNumber,
            ...item,
          }
        }
        return item
      })
      const res = await post({
        url: 'wms/yarnInStock/updateInfo',
        data: paramsArr,
      })
      if (res.code == 200) {
        console.log('res', res)
        cxYcList()
        Message.success('修改成功')
        editVisible.value = false
        resetEditData()
      } else {
        Message.error(res.message)
      }
    } catch (e) {
      console.log(e)
    }
  }
  const editDrawerCancel = () => {
    editVisible.value = false
    resetEditData()
  }
  //初始点击修改弹窗行表格数据
  const deletedInitData = ref<any>([])
  const editHandler = async (data: any) => {
    try {
      editVisible.value = true
      deletedInitData.value = []
      const res = await post({
        url: 'wms/yarnInStock/getList',
        data: {
          in_stock_number: data.inStockNumber,
        },
      })
      if (res.code == 200) {
        console.log('res', res)
        editData.firmName = res.data[0].firm
        editData.firmId = res.data[0].firmId
        editData.warehouseName = res.data[0].warehouse
        editData.warehouseId = res.data[0].warehouseId
        editData.inStockType = res.data[0].inStockType
        editData.customName = res.data[0].customName
        editData.customOrderNo = res.data[0].customOrderNo
        editData.transportName = res.data[0].transportName
        editData.inStockNumber = res.data[0].inStockNumber
        nextTick(() => {
          gridOptioncg4?.value.setRowData(res.data)
        })
      } else {
        ElMessage.error(res.msg)
      }
    } catch (e) {
      console.log(e)
    }
  }
  const resetEditData = () => {
    editData.firmName = ''
    editData.firmId = ''
    editData.warehouseName = ''
    editData.warehouseId = ''
    editData.inStockType = ''
    editData.customName = ''
    editData.customOrderNo = ''
    editData.transportName = ''
    editData.inStockNumber = ''
  }
  onMounted(async () => {
    updateGridState01()
    updateGridState02()
    updateGridState03()
    updateGridState04()
    updateGridState05()
    await whChange()
    cxYcList()
    emitter.on('ReceiptList3-EditHandle', (data: any) => editHandler(data))
  })
  onUnmounted(() => {
    emitter.off('ReceiptList3-EditHandle', (data: any) => editHandler(data))
  })
  const tabsKeys = ref(1)

  const tabsChanges = (e: any) => {
    tabsKeys.value = e
    if (e == 1) {
      toolbarList.value = [
        `${permissionStore.hasPermisson('ylrk.rkdglcx') ? '查询' : ''}`,
        `${permissionStore.hasPermisson('ylrk.xzrlrk') ? '新增原料入库' : ''}`,
        `${permissionStore.hasPermisson('ylrk.sh') ? '审核' : ''}`,
        `${permissionStore.hasPermisson('ylrk.sc') ? '删除' : ''}`,
        `${permissionStore.hasPermisson('ylrk.yscrkqxsh') ? '取消审核' : ''}`,
      ]
      cxYcList()
      console.log('1', toolbarList.value)
    } else if (e == 2) {
      toolbarList.value = [`${permissionStore.hasPermisson('ylrk.cgshdclcx') ? '查询' : ''}`]
      cxDbsList()
    } else if (e == 3) {
      toolbarList.value = [
        `${permissionStore.hasPermisson('ylrk.dbrkdclcx') ? '查询' : ''}`,
        `${permissionStore.hasPermisson('ylrk.dbrkdclrk') ? '入库' : ''}`,
      ]
      cxCgsList()
    } else if (e == 4) {
      ;(toolbarList.value = [
        `${permissionStore.hasPermisson('ylrk.dbrkyclcx') ? '查询' : ''}`,
        `${permissionStore.hasPermisson('ylrk.yscrk.dbrkyclqxsh') ? '取消审核' : ''}`,
      ]),
        cxCgsList2()
    } else if (e == 5) {
      toolbarList.value = ['查询', '入库']
      cjOutIntSelect()
    }
  }

  const cxDbsList = () => {
    var startDate: any
    var endDate: any
    if (pageData.dropDownTime.length == 0) {
      startDate = ''
      endDate = ''
    } else {
      startDate = pageData.dropDownTime[0]
      endDate = pageData.dropDownTime[1]
    }
    post({
      url: 'wms/goodsReceivyNote/getPage',
      data: {
        page: fySelet3.page,
        size: fySelet3.size,
        receiveState: 0,
        firmId: pageData.a,
        warehouseId: pageData.b,
        yarnCode: pageData.yarnCode,
        yarnName: pageData.yarnName,
        yarnBrand: pageData.yarnBrand,
        productionBatch: pageData.productionBatch,
        level: pageData.level,
        startDate: compareDate(startDate, endDate) == true ? endDate : startDate,
        endDate: compareDate(startDate, endDate) == true ? startDate : endDate,
      },
    }).then((res: any) => {
      setTableTotalRow(gridOption3, res.data.list, [
        'pieceNumber',
        'bulkNumber',
        'bulkWeight',
        'pieceWeightTotal',
        'weightTotal',
      ])
      gridOption3.value.setRowData(res.data.list)
      tableDataList3.value = res.data.list
      fySelet3.total = res.data.total
    })
  }
  const cxYcList = () => {
    var startDate: any
    var endDate: any
    if (pageData.dropDownTime.length == 0) {
      startDate = ''
      endDate = ''
    } else {
      startDate = pageData.dropDownTime[0]
      endDate = pageData.dropDownTime[1]
    }
    post({
      url: 'wms/yarnInStock/getPage',
      data: {
        page: fySelet2.page,
        size: fySelet2.size,
        firm_id: pageData.a,
        warehouse_id: pageData.b,
        yarn_code: pageData.yarnCode,
        yarn_name: pageData.yarnName,
        yarn_brand: pageData.yarnBrand,
        production_batch: pageData.productionBatch,
        level: pageData.level,
        startDate: compareDate(startDate, endDate) == true ? endDate : startDate,
        endDate: compareDate(startDate, endDate) == true ? startDate : endDate,
        audit_state: pageData.audit_state,
        inStockTypeList:pageData.inStockTypes
      },
    }).then((res: any) => {
      setTableTotalRow(gridOption, res.data.list, [
        'pieceNumber',
        'bulkCount',
        'bulkNumber',
        'bulkWeight',
        'weightTotal',
      ])
      gridOption.value.setRowData(res.data.list)
      tableDataList.value = res.data.list
      fySelet2.total = res.data.total
    })
  }

  const redersOut = () => {
    if (tabsKeys.value == 3) {
      if (gridOption2.value.getSelectedRows().length < 1) {
        Message.error('请勾选数据')
        return
      }
      let objListSet = new Set(
        gridOption2.value.getSelectedRows().map((res: any) => {
          return res.transferNumber
        })
      )
      if (objListSet.size > 1) {
        Message.error('请勾选相同调拨单')
        return
      }
      post({
        url: '/wms/yarnTransferStock/getListByTransferNumber',
        data: Array.from(objListSet),
      }).then((is: any) => {
        if (is.code == 200) {
          cgData4.value = is.data
          cgOut.visible2 = true
        } else {
          Message.error(is.message)
        }
      })
    } else if (tabsKeys.value == 2) {
      if (gridOption3.value.getSelectedRows().length == 0) {
        Message.error('请选择调拨单')
        return
      }
      for (let i = 0; i < gridOption3.value.getSelectedRows().length; i++) {
        for (let j = i + 1; j < gridOption3.value.getSelectedRows().length; j++) {
          if (
            gridOption3.value.getSelectedRows()[i].orderNo !=
            gridOption3.value.getSelectedRows()[j].orderNo
          ) {
            Message.error('请勾选相同调拨单入库')
            return
          }
        }
      }
      cgData2.value = JSON.parse(JSON.stringify(gridOption3.value.getSelectedRows()))
      cgOut.visible = true
    } else if (tabsKeys.value == 5) {
      if (gridOption5.value.getSelectedRows().length == 0) {
        Message.error('请勾选数据')
        return false
      }
      for (let i = 0; i < gridOption5.value.getSelectedRows().length; i++) {
        if (gridOption5.value.getSelectedRows()[i].stockInState == 1) {
          Message.error('已入库')
          return false
        }
      }
      cgData5.value = JSON.parse(JSON.stringify(gridOption5.value.getSelectedRows()))
      cgData5.value.forEach((item: any) => {
        item.pieceCount1 = item.pieceCount
        item.pieceNumber1 = item.pieceNumber
        item.pieceWeight1 = item.pieceWeight
        item.bulkCount1 = item.bulkCount
        item.bulkNumber1 = item.bulkNumber
        item.bulkWeight1 = item.bulkWeight
        item.weightTotal1 = item.weightTotal
        item.pieceNumber = item.pieceNumber1 - item.warehousePieceNum
        item.bulkNumber = item.bulkNumber1 - item.warehouseBulkNum
        item.weightTotal = item.weightTotal1 - item.warehouseReturnNum
      })
      cgOut.visible5 = true
    }
  }
  const cgHandleOk5 = async () => {
    // Modal.confirm({
    //         title: '系统提示',
    //         content: '确认入库选中的数据?',
    //         onOk: () => {
    //             post({
    //                 url: 'wms/yarnInStock/stockOnAuditStateByReturn',
    //                 data: gridOption5.value.getSelectedRows()
    //             }).then((res: any) => {
    //                 if (res.code == 200) {
    //                     Message.success('成功')
    //                     cjOutIntSelect()
    //                 } else (
    //                     Message.error(res.message)
    //                 )
    //             })
    //         },
    //     })
    let fly = true
    // console.log(cgData5.value, '像云端，山那边');
    cgData5.value.forEach((item: any) => {
      if (item.weightTotal > item.weightTotal1 - item.warehouseReturnNum) {
        fly = false
      }
    })
    // console.log(fly, 'hhhhhhhhhhhhhh');
    if (fly) {
      const { code, message } = await post({
        url: 'wms/yarnInStock/stockOnAuditStateByReturn',
        data: cgData5.value,
      })
      if (code == 200) {
        cjOutIntSelect()
        Message.success('成功')
        return true
      }
      Message.error(message)
      return false
    } else {
      Message.warning('入库总重量超出了现有总重量！')
      return false
    }
  }
  const cadelvs5 = () => {
    cgData5.value = []
    cgOut.visible5 = false
  }
  const cahngesCount = (record: any) => {
    if (record.pieceNumber && record.bulkWeight && record.pieceWeight1 != 0) {
      nextTick(() => {
        record.weightTotal = record.pieceNumber * record.pieceWeight1 + record.bulkWeight
      })
    } else if (record.pieceNumber && record.pieceWeight1 != 0) {
      nextTick(() => {
        record.weightTotal = record.pieceNumber * record.pieceWeight1
      })
    } else if (record.bulkWeight) {
      nextTick(() => {
        record.weightTotal = record.bulkWeight
      })
    } else {
      nextTick(() => {
        record.weightTotal = 0
      })
    }
  }

  const cgOut = reactive({
    visible: false,
    visible2: false,
    visible5: false,
    title: '采购单入库',
  })

  const cgHandleOk = async () => {
    for (let i = 0; i < cgData2.value.length; i++) {
      if (
        cgData2.value[i].weightTotal == '' ||
        cgData2.value[i].weightTotal == undefined ||
        cgData2.value[i].weightTotal == null ||
        cgData2.value[i].weightTotal == 0
      ) {
        Message.error('总数量必须大于0')
        return false
      }
      if (
        cgData2.value[i]['transportName'] == '' ||
        cgData2.value[i]['transportName'] == undefined ||
        cgData2.value[i]['transportName'] == null
      ) {
        Message.error('搬运计件必填!')
        return false
      }
      if (
        cgData2.value[i]['productionBatch'] == '' ||
        cgData2.value[i]['productionBatch'] == undefined ||
        cgData2.value[i]['productionBatch'] == null
      ) {
        Message.error('纱批必填!')
        return false
      }
      
      if (cgData2.value[i]['pieceNumber'] > 0) {
        if (
          cgData2.value[i]['pieceCount'] == '' ||
          cgData2.value[i]['pieceCount'] == undefined ||
          cgData2.value[i]['pieceCount'] == null ||
          cgData2.value[i]['pieceCount'] == 0
        ) {
          Message.error('请录入整件个数!')
          return false
        }
      }
    }
    const params = cgData2.value.map((item: any) => {
      return {
        ...item,
        productionDateStart: dayjs(new Date(item.productionDateStart)).format(
          'YYYY-MM-DD HH:mm:ss.SSS'
        ),
        productionDateEnd: dayjs(new Date(item.productionDateEnd)).format(
          'YYYY-MM-DD HH:mm:ss.SSS'
        ),
      }
    })
    const { code, message } = await post({
      url: 'wms/yarnInStock/stockInByGoodsReceivingNote',
      data: params,
    })

    if (code == 200) {
      post({
        url: 'wms/yarnInStock/releaseLockByGoodsReceivingNote',
        data: {
          receiptNumber: receiptNumberS,
        },
      }).then((res: any) => {
        if (res.code == 200) {
          cxYcList()
          cxDbsList()
          Message.success('成功')
          return true
        }
      })
    } else {
      Message.error(message)
      return false
    }
  }

  const cgColumns2: any = [
    {
      dataIndex: 'receiptNumber',
      field: 'receiptNumber',
      headerName: '收货单号',
      width: 150,
    },
    {
      dataIndex: 'purchaseCode',
      field: 'purchaseCode',
      headerName: '采购单号',
      width: 150,
    },
    {
      dataIndex: 'firm',
      field: 'firm',
      headerName: '公司',
      width: 150,
    },
    {
      dataIndex: 'warehouse',
      field: 'warehouse',
      headerName: '仓库',
      width: 150,
    },
    {
      dataIndex: 'inStockType',
      field: 'inStockType',
      headerName: '入库类型',
      width: 150,
    },
    {
      dataIndex: 'transportName',
      field: 'transportName',
      headerName: '搬运计件',
      slotName: 'transportName',
      width: 250,
      cellRenderer: {
        template: `
        <a-select popup-container="html" class="bacClass" v-model="record.transportName" allow-clear allow-search
                  @focus="focusEvent"
                  style="width: 200px" :title="record.transportName">
          <a-option v-for="(item, index) in pageData.transportNameList" :value="item.transportName">{{
              item.transportName
            }}
          </a-option>
        </a-select>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const focusEvent = (b: any) => {
            focusTransportName(b)
          }

          return {
            record,
            focusEvent,
            pageData,
          }
        },
      },
    },
    {
      dataIndex: 'supplier',
      field: 'supplier',
      headerName: '供应商名称',
      slotName: 'supplier',
      width: 150,
    },
    {
      dataIndex: 'customName',
      field: 'customName',
      headerName: '客户名称 ',
      width: 150,
    },
    {
      dataIndex: 'yarnCode',
      field: 'yarnCode',
      headerName: '原料编号',
      width: 150,
    },
    {
      dataIndex: 'yarnName',
      field: 'yarnName',
      headerName: '纱线名称',
      width: 150,
    },
    {
      dataIndex: 'yarnBrand',
      field: 'yarnBrand',
      headerName: '纱牌',
      width: 150,
    },
    {
      dataIndex: 'productionBatch',
      field: 'productionBatch',
      headerName: '纱批',
      slotName: 'productionBatch',
      width: 250,
      cellRenderer: {
        template: `<a-input v-model="record.productionBatch" class="bacClass" />
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          return {
            record,
          }
        },
      },
    },
    {
      dataIndex: 'level',
      field: 'level',
      headerName: '等级',
      width: 150,
    },
    // {
    //     dataIndex: 'matchColor',
    //     field: 'matchColor',
    //     headerName: '可配色称',
    //     width: 150,
    // },
    {
      dataIndex: 'colorCode',
      field: 'colorCode',
      // slotName: 'level',
      headerName: '色号',
      // fixed: 'right',
      width: 150,
    },
    {
      dataIndex: 'colorName',
      field: 'colorName',
      headerName: '色称',
      width: 150,
    },
    {
      dataIndex: 'pieceCount',
      field: 'pieceCount',
      headerName: '整件个数',
      slotName: 'pieceCount',
      width: 150,
      cellRenderer: {
        template: `
        <a-input-number class="bacClass" v-model="record.pieceCount" :precision="2"></a-input-number>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          return {
            record,
          }
        },
      },
    },
    {
      dataIndex: 'pieceNumber',
      field: 'pieceNumber',
      headerName: '整件/件数',
      slotName: 'pieceNumber',
      width: 150,
      cellRenderer: {
        template: `
        <a-input-number @change="changeEvent" class="bacClass" v-model="record.pieceNumber"></a-input-number>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const changeEvent = () => {
            cahngesCount4(record)
          }
          return {
            record,
            changeEvent,
          }
        },
      },
    },
    {
      dataIndex: 'pieceWeight',
      field: 'pieceWeight',
      headerName: '整件/件重',
      width: 150,
    },
    {
      dataIndex: 'bulkCount',
      field: 'bulkCount',
      headerName: '散件个数',
      slotName: 'bulkCount',
      width: 150,
      cellRenderer: {
        template: `
        <a-input-number class="bacClass" v-model="record.bulkCount" :precision="2"></a-input-number>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          return {
            record,
          }
        },
      },
    },
    {
      dataIndex: 'bulkNumber',
      field: 'bulkNumber',
      headerName: '散件/件数',
      slotName: 'bulkNumber',
      width: 150,
      cellRenderer: {
        template: `
        <a-input-number :min="0" class="bacClass" v-model="record.bulkNumber" name="input"
                        :precision="2"></a-input-number>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          return {
            record,
          }
        },
      },
    },
    {
      dataIndex: 'bulkWeight',
      field: 'bulkWeight',
      headerName: '散件/件重',
      slotName: 'bulkWeight',
      width: 150,
      cellRenderer: {
        template: `
        <a-input-number :min="0" class="bacClass" v-model="record.bulkWeight" name="input"
        @change="changeEvent" :precision="2"></a-input-number>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const changeEvent = () => {
            cahngesCount4(record)
          }
          return {
            record,
            changeEvent,
          }
        },
      },
    },
    {
      dataIndex: 'weightTotal',
      field: 'weightTotal',
      headerName: '总重量',
      width: 150,
    },
    {
      dataIndex: 'packingFeature',
      field: 'packingFeature',
      headerName: '包装特征',
      slotName: 'packingFeature',
      width: 150,
      cellRenderer: {
        template: `
        <a-input class="bacClass" v-model="record.packingFeature" name="input"></a-input>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          return {
            record,
          }
        },
      },
    },
    {
      dataIndex: 'unit',
      field: 'unit',
      headerName: '单位',
      slotName: 'unit',
      width: 150,
    },
    {
      dataIndex: 'location',
      field: 'location',
      headerName: '库位',
      width: 150,
    },
    {
      dataIndex: 'productionDateStart',
      field: 'productionDateStart',
      headerName: '生产日期开始',
      width: 200,
      slotName: 'productionDateStart',
      cellRenderer: {
        template: `
        <a-date-picker popup-container="html" v-model="record.productionDateStart"/>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          return {
            record,
          }
        },
      },
    },
    {
      dataIndex: 'productionDateEnd',
      field: 'productionDateEnd',
      headerName: '生产日期结束',
      width: 200,
      slotName: 'productionDateEnd',
      cellRenderer: {
        template: `
        <a-date-picker popup-container="html" v-model="record.productionDateEnd"/>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          return {
            record,
          }
        },
      },
    },
    {
      dataIndex: 'paperBone',
      field: 'paperBone',
      headerName: '纸骨',
      width: 150,
      slotName: 'paperBone',
      cellRenderer: {
        template: `
        <a-input class="bacClass" v-model="record.paperBone"></a-input>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          return {
            record,
          }
        },
      },
    },
    {
      dataIndex: 'testYarnState',
      field: 'testYarnState',
      headerName: '是否试纱',
      width: 150,
      slotName: 'testYarnState',
      cellRenderer: {
        template: `
        <a-select popup-container="html" class="bacClass" v-model="record.testYarnState" allow-clear allow-search>
          <a-option :value="0">否</a-option>
          <a-option :value="1">是</a-option>
        </a-select>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          return {
            record,
          }
        },
      },
    },
    {
      dataIndex: 'detectionState',
      field: 'detectionState',
      headerName: '是否检测',
      slotName: 'detectionState',
      width: 150,
      cellRenderer: {
        template: `
        <a-select popup-container="html" class="bacClass" v-model="record.detectionState" allow-clear allow-search>
          <a-option :value="0">否</a-option>
          <a-option :value="1">是</a-option>
        </a-select>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          return {
            record,
          }
        },
      },
    },
    {
      dataIndex: 'remark',
      field: 'remark',
      headerName: '备注',
      width: 300,
    },
  ]
  //新增原料入库表头
  const cgColumns3: any = [
    {
      dataIndex: 'firm',
      field: 'firm',
      headerName: '公司',
      width: 150,
    },
    {
      dataIndex: 'warehouse',
      field: 'warehouse',
      headerName: '仓库',
      width: 150,
    },
    {
      dataIndex: 'inStockType',
      field: 'inStockType',
      slotName: 'inStockType',
      headerName: '入库类型',
      width: 150,
    },
    {
      dataIndex: 'supplier',
      field: 'supplier',
      slotName: 'supplier',
      headerName: '供应商名称',
      width: 200,
      cellRenderer: {
        template: `
        <a-select popup-container="html" class="bacClass" @click="clickEvent" :style="{ width: '100%' }"
                  v-model="record.supplier" allow-search
                  allow-clear @search="handleSearch($event, record)" name="input" @keyup.enter="enterEvent">
          <a-option v-for="item in supplierCxList" :value="item.providerName">
            {{ item.providerName }}
          </a-option>
        </a-select>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const handleSearch = (a: any, b: any) => {
            handleSearch2(a, b)
          }
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          const clickEvent = () => {
            supplierCx()
          }
          return {
            record,
            supplierCxList,
            handleSearch,
            clickEvent,
            enterEvent,
          }
        },
      },
    },
    {
      dataIndex: 'customName',
      field: 'customName',
      slotName: 'customName',
      headerName: '客户名称 ',
      width: 150,
    },
    {
      dataIndex: 'customOrderNo',
      field: 'customOrderNo',
      slotName: 'customOrderNo',
      headerName: '客户订单号 ',
      width: 150,
    },
    {
      dataIndex: 'yarnCode',
      field: 'yarnCode',
      headerName: '原料编号',
      width: 150,
    },
    {
      dataIndex: 'yarnName',
      field: 'yarnName',
      headerName: '原料名称',
      width: 150,
    },
    {
      dataIndex: 'yarnBrand',
      field: 'yarnBrand',
      headerName: '纱牌',
      slotName: 'yarnBrand',
      width: 200,
      cellRenderer: {
        template: `
        <a-select popup-container="html" class="bacClass" @click="clickEvent(record)" :style="{ width: '10rem' }"
                  v-model="record.yarnBrand"
                  allow-search allow-clear allow-create @search="searchEvent($event, record)" name="input"
                  @keyup.enter="enterEvent">
          <a-option v-for="item in yarnBrandList" :value="item.yarnBrand">
            {{ item.yarnBrand }}
          </a-option>
        </a-select>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const searchEvent = (a: any, b: any) => {
            handleSearch(a, b)
          }
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          const clickEvent = (record: any) => {
            yarnBrandClick(record)
          }
          return {
            record,
            yarnBrandList,
            searchEvent,
            clickEvent,
            enterEvent,
          }
        },
      },
    },
    {
      dataIndex: 'productionBatch',
      field: 'productionBatch',
      headerName: '纱批',
      slotName: 'productionBatch',
      width: 200,
      cellRenderer: {
        template: `
        <a-select popup-container="html" class="bacClass" @click="clickEvent(record)" :style="{ width: '10rem' }"
                  v-model="record.productionBatch"
                  allow-search allow-clear allow-create @search="searchEvent($event, record)" name="input"
                  @keyup.enter="enterEvent">
          <a-option v-for="item in productionBatchLisy" :value="item.productionBatch">
            {{ item.productionBatch }}
          </a-option>
        </a-select>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const searchEvent = (a: any, b: any) => {
            handleSearch1(a, b)
          }
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          const clickEvent = (record: any) => {
            productionBatchClick(record)
          }
          return {
            record,
            productionBatchLisy,
            searchEvent,
            clickEvent,
            enterEvent,
          }
        },
      },
    },
    {
      dataIndex: 'level',
      field: 'level',
      slotName: 'level',
      headerName: '等级',
      width: 150,
      cellRenderer: {
        template: `
        <a-input class="bacClass" v-model="record.level" @change="changeEvent(record)" name="input"
                 @keyup.enter="enterEvent"></a-input>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          const changeEvent = (record: any) => {
            laveChang(record)
          }
          return {
            record,
            changeEvent,
            enterEvent,
          }
        },
      },
    },
    // {
    //     dataIndex: 'matchColor',
    //     field: 'matchColor',
    //     headerName: '可配色称',
    //     slotName: 'matchColor',
    //     width: 150,
    // },
    {
      dataIndex: 'colorCode',
      field: 'colorCode',
      slotName: 'colorCode',
      headerName: '色号',
      // fixed: 'right',
      width: 150,
      cellRenderer: {
        template: `
        <a-input class="bacClass" v-model="record.colorCode" @change="changeEvent(record)" name="input"
                 @keyup.enter="enterEvent"></a-input>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          const changeEvent = (record: any) => {
            // matchColorChang(record)
          }
          return {
            record,
            changeEvent,
            enterEvent,
          }
        },
      },
    },
    {
      dataIndex: 'colorName',
      field: 'colorName',
      slotName: 'colorName',
      headerName: '色称',
      width: 150,
      cellRenderer: {
        template: `
        <a-input class="bacClass" v-model="record.colorName" @change="changeEvent(record)" name="input"
                 @keyup.enter="enterEvent"></a-input>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          const changeEvent = (record: any) => {
            colorNameChang(record)
          }
          return {
            record,
            changeEvent,
            enterEvent,
          }
        },
      },
    },
    {
      dataIndex: 'pieceCount',
      field: 'pieceCount',
      headerName: '整件/个数',
      slotName: 'pieceCount',
      width: 150,
      cellRenderer: {
        template: `
        <a-input-number :min="0" class="bacClass" v-model="record.pieceCount" name="input" @keyup.enter="enterEvent"
                        :precision="2"></a-input-number>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          return {
            record,
            enterEvent,
          }
        },
      },
    },
    {
      dataIndex: 'pieceNumber',
      field: 'pieceNumber',
      headerName: '整件/件数',
      slotName: 'pieceNumber',
      width: 150,
      cellRenderer: {
        template: `
        <a-input-number :min="0" class="bacClass" v-model="record.pieceNumber" @change="changeEvent(record)"
                        name="input" @keyup.enter="enterEvent"
                        :precision="2"></a-input-number>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          const changeEvent = (record: any) => {
            jiHUsn4(record)
          }
          return {
            record,
            enterEvent,
            changeEvent,
          }
        },
      },
    },
    {
      dataIndex: 'pieceWeight',
      field: 'pieceWeight',
      headerName: '整件/件重',
      slotName: 'pieceWeight',
      width: 150,
      cellRenderer: {
        template: `
        <a-input-number :min="0" class="bacClass" v-model="record.pieceWeight" @change="changeEvent(record)"
                        name="input" @keyup.enter="enterEvent"
                        :precision="2"></a-input-number>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          const changeEvent = (record: any) => {
            jiHUsn4(record)
          }
          return {
            record,
            enterEvent,
            changeEvent,
          }
        },
      },
    },
    {
      dataIndex: 'bulkCount',
      field: 'bulkCount',
      headerName: '散件/个数',
      slotName: 'bulkCount',
      width: 150,
      cellRenderer: {
        template: `
        <a-input-number :min="0" class="bacClass" v-model="record.bulkCount" name="input" @keyup.enter="enterEvent"
                        :precision="2"></a-input-number>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          return {
            record,
            enterEvent,
          }
        },
      },
    },
    {
      dataIndex: 'bulkNumber',
      field: 'bulkNumber',
      headerName: '散件/件数',
      slotName: 'bulkNumber',
      width: 150,
      cellRenderer: {
        template: `
        <a-input-number :min="0" class="bacClass" v-model="record.bulkNumber" name="input" @change="changeEvent(record)"
                        @keyup.enter="enterEvent"
                        :precision="2"></a-input-number>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          const changeEvent = (record: any) => {
            jiHUsn3(record)
          }
          return {
            record,
            enterEvent,
            changeEvent,
          }
        },
      },
    },
    {
      dataIndex: 'bulkWeight',
      field: 'bulkWeight',
      headerName: '散件/散重',
      slotName: 'bulkWeight',
      width: 150,
      cellRenderer: {
        template: `
        <a-input-number :min="0" class="bacClass" v-model="record.bulkWeight" @change="changeEvent(record)" name="input"
                        @keyup.enter="enterEvent"
                        :precision="2"></a-input-number>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          const changeEvent = (record: any) => {
            jiHUsn3(record)
          }
          return {
            record,
            enterEvent,
            changeEvent,
          }
        },
      },
    },
    {
      dataIndex: 'weightTotal',
      field: 'weightTotal',
      headerName: '总重量',
      width: 150,
      cellRenderer: {
        template: `
        <a-input v-model="record.weightTotal" name="input" :disabled='true'></a-input>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          return {
            record,
          }
        },
      },
    },
    {
      dataIndex: 'packing',
      field: 'packing',
      headerName: '包装',
      slotName: 'packing',
      width: 150,
      cellRenderer: {
        template: `
        <a-input class="bacClass" v-model="record.packing" name="input" @keyup.enter="enterEvent"></a-input>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          return {
            record,
            enterEvent,
          }
        },
      },
    },
    {
      dataIndex: 'packingFeature',
      field: 'packingFeature',
      headerName: '包装特征',
      slotName: 'packingFeature',
      width: 150,
      cellRenderer: {
        template: `
        <a-input class="bacClass" v-model="record.packingFeature" name="input" @keyup.enter="enterEvent"></a-input>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          return {
            record,
            enterEvent,
          }
        },
      },
    },
    {
      dataIndex: 'sourceNumber',
      field: 'sourceNumber',
      headerName: '入库来源',
      width: 150,
    },
    {
      dataIndex: 'unit',
      field: 'unit',
      headerName: '单位',
      slotName: 'unit',
      width: 150,
    },
    {
      dataIndex: 'location',
      field: 'location',
      slotName: 'location',
      headerName: '库位',
      width: 150,
      cellRenderer: {
        template: `
        <a-input class="bacClass" v-model="record.location" name="input" @keyup.enter="enterEvent"></a-input>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          return {
            record,
            enterEvent,
          }
        },
      },
    },
    {
      headerName: '生产日期开始',
      field: 'productionDateStart',
      slotName: 'productionDateStart',
      width: 200,
      cellRenderer: {
        template: `
        <a-date-picker popup-container="html" v-model="record.productionDateStart" class="bacClass"
                       :style="{ width: '9rem' }"/>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          return {
            record,
          }
        },
      },
    },
    {
      headerName: '生产日期结束',
      field: 'productionDateEnd',
      slotName: 'productionDateEnd',
      width: 200,
      cellRenderer: {
        template: `
        <a-date-picker popup-container="html" v-model="record.productionDateEnd" class="bacClass"
                       :style="{ width: '9rem' }"/>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          return {
            record,
          }
        },
      },
    },
    {
      dataIndex: 'paperBone',
      field: 'paperBone',
      headerName: '纸骨',
      width: 150,
      slotName: 'paperBone',
      cellRenderer: {
        template: `
        <a-input class="bacClass" v-model="record.paperBone"></a-input>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          return {
            record,
          }
        },
      },
    },
    {
      dataIndex: 'remark',
      field: 'remark',
      slotName: 'remark',
      headerName: '备注',
      width: 150,
      cellRenderer: {
        template: `
        <a-input class="bacClass" v-model="record.remark" name="input" @keyup.enter="enterEvent"></a-input>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          return {
            record,
            enterEvent,
          }
        },
      },
    },
    {
      dataIndex: 'acFighs',
      field: 'acFighs',
      slotName: 'acFighs',
      headerName: '操作',
      pinned: 'right',
      width: 100,
      cellRenderer: {
        template: `
        <a-button type="primary" @click="clickEvent(record)" size="mini">删除</a-button>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const clickEvent = (b: any) => {
            delLine(b)
          }
          return {
            record,
            clickEvent,
          }
        },
      },
    },
  ]
  const delLine = (e: any) => {
    Modal.confirm({
      title: '系统提示',
      content: '确认删除选中的数据?',
      onOk: () => {
        cgData3.value = cgData3.value.filter((val: any) => {
          return val != e
        })
      },
    })
  }
  //修改原料入库表头
  const cgColumns6: any = [
    // {
    //   dataIndex: 'firm',
    //   field: 'firm',
    //   headerName: '公司',
    //   width: 150,
    // },
    // {
    //   dataIndex: 'warehouse',
    //   field: 'warehouse',
    //   headerName: '仓库',
    //   width: 150,
    // },
    // {
    //   dataIndex: 'inStockType',
    //   field: 'inStockType',
    //   slotName: 'inStockType',
    //   headerName: '入库类型',
    //   width: 150,
    // },
    {
      dataIndex: 'supplier',
      field: 'supplier',
      slotName: 'supplier',
      headerName: '供应商名称',
      width: 200,
      cellRenderer: {
        template: `
        <a-select popup-container="html" class="bacClass" @click="clickEvent" :style="{ width: '100%' }"
                  v-model="record.supplier" allow-search
                  allow-clear @search="handleSearch($event, record)" name="input" @keyup.enter="enterEvent">
          <a-option v-for="item in supplierCxList" :value="item.providerName">
            {{ item.providerName }}
          </a-option>
        </a-select>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const handleSearch = (a: any, b: any) => {
            handleSearch2(a, b)
          }
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          const clickEvent = () => {
            supplierCx()
          }
          return {
            record,
            supplierCxList,
            handleSearch,
            clickEvent,
            enterEvent,
          }
        },
      },
    },
    // {
    //   dataIndex: 'customName',
    //   field: 'customName',
    //   slotName: 'customName',
    //   headerName: '客户名称 ',
    //   width: 150,
    // },
    // {
    //   dataIndex: 'customOrderNo',
    //   field: 'customOrderNo',
    //   slotName: 'customOrderNo',
    //   headerName: '客户订单号 ',
    //   width: 150,
    // },
    {
      dataIndex: 'yarnCode',
      field: 'yarnCode',
      headerName: '原料编号',
      width: 150,
    },
    {
      dataIndex: 'yarnName',
      field: 'yarnName',
      headerName: '原料名称',
      width: 150,
    },
    {
      dataIndex: 'yarnBrand',
      field: 'yarnBrand',
      headerName: '纱牌',
      slotName: 'yarnBrand',
      width: 200,
      cellRenderer: {
        template: `
        <a-select popup-container="html" class="bacClass" @click="clickEvent(record)" :style="{ width: '10rem' }"
                  v-model="record.yarnBrand"
                  allow-search allow-clear allow-create @search="searchEvent($event, record)" name="input"
                  @keyup.enter="enterEvent">
          <a-option v-for="item in yarnBrandList" :value="item.yarnBrand">
            {{ item.yarnBrand }}
          </a-option>
        </a-select>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const searchEvent = (a: any, b: any) => {
            handleSearch(a, b)
          }
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          const clickEvent = (record: any) => {
            yarnBrandClick(record)
          }
          return {
            record,
            yarnBrandList,
            searchEvent,
            clickEvent,
            enterEvent,
          }
        },
      },
    },
    {
      dataIndex: 'productionBatch',
      field: 'productionBatch',
      headerName: '纱批',
      slotName: 'productionBatch',
      width: 200,
      cellRenderer: {
        template: `
        <a-select popup-container="html" class="bacClass" @click="clickEvent(record)" :style="{ width: '10rem' }"
                  v-model="record.productionBatch"
                  allow-search allow-clear allow-create @search="searchEvent($event, record)" name="input"
                  @keyup.enter="enterEvent">
          <a-option v-for="item in productionBatchLisy" :value="item.productionBatch">
            {{ item.productionBatch }}
          </a-option>
        </a-select>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const searchEvent = (a: any, b: any) => {
            handleSearch1(a, b)
          }
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          const clickEvent = (record: any) => {
            productionBatchClick(record)
          }
          return {
            record,
            productionBatchLisy,
            searchEvent,
            clickEvent,
            enterEvent,
          }
        },
      },
    },
    {
      dataIndex: 'level',
      field: 'level',
      slotName: 'level',
      headerName: '等级',
      width: 150,
      cellRenderer: {
        template: `
        <a-input class="bacClass" v-model="record.level" @change="changeEvent(record)" name="input"
                 @keyup.enter="enterEvent"></a-input>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          const changeEvent = (record: any) => {
            laveChang(record)
          }
          return {
            record,
            changeEvent,
            enterEvent,
          }
        },
      },
    },
    // {
    //     dataIndex: 'matchColor',
    //     field: 'matchColor',
    //     headerName: '可配色称',
    //     slotName: 'matchColor',
    //     width: 150,
    // },
    {
      dataIndex: 'colorCode',
      field: 'colorCode',
      slotName: 'colorCode',
      headerName: '色号',
      // fixed: 'right',
      width: 150,
      cellRenderer: {
        template: `
        <a-input class="bacClass" v-model="record.colorCode" @change="changeEvent(record)" name="input"
                 @keyup.enter="enterEvent"></a-input>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          const changeEvent = (record: any) => {
            // matchColorChang(record)
          }
          return {
            record,
            changeEvent,
            enterEvent,
          }
        },
      },
    },
    {
      dataIndex: 'colorName',
      field: 'colorName',
      slotName: 'colorName',
      headerName: '色称',
      width: 150,
      cellRenderer: {
        template: `
        <a-input class="bacClass" v-model="record.colorName" @change="changeEvent(record)" name="input"
                 @keyup.enter="enterEvent"></a-input>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          const changeEvent = (record: any) => {
            colorNameChang(record)
          }
          return {
            record,
            changeEvent,
            enterEvent,
          }
        },
      },
    },
    {
      dataIndex: 'pieceCount',
      field: 'pieceCount',
      headerName: '整件/个数',
      slotName: 'pieceCount',
      width: 150,
      cellRenderer: {
        template: `
        <a-input-number :min="0" class="bacClass" v-model="record.pieceCount" name="input" @keyup.enter="enterEvent"
                        :precision="2"></a-input-number>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          return {
            record,
            enterEvent,
          }
        },
      },
    },
    {
      dataIndex: 'pieceNumber',
      field: 'pieceNumber',
      headerName: '整件/件数',
      slotName: 'pieceNumber',
      width: 150,
      cellRenderer: {
        template: `
        <a-input-number :min="0" class="bacClass" v-model="record.pieceNumber" @change="changeEvent(record)"
                        name="input" @keyup.enter="enterEvent"
                        :precision="2"></a-input-number>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          const changeEvent = (record: any) => {
            jiHUsn4(record)
          }
          return {
            record,
            enterEvent,
            changeEvent,
          }
        },
      },
    },
    {
      dataIndex: 'pieceWeight',
      field: 'pieceWeight',
      headerName: '整件/件重',
      slotName: 'pieceWeight',
      width: 150,
      cellRenderer: {
        template: `
        <a-input-number :min="0" class="bacClass" v-model="record.pieceWeight" @change="changeEvent(record)"
                        name="input" @keyup.enter="enterEvent"
                        :precision="2"></a-input-number>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          const changeEvent = (record: any) => {
            jiHUsn4(record)
          }
          return {
            record,
            enterEvent,
            changeEvent,
          }
        },
      },
    },
    {
      dataIndex: 'bulkCount',
      field: 'bulkCount',
      headerName: '散件/个数',
      slotName: 'bulkCount',
      width: 150,
      cellRenderer: {
        template: `
        <a-input-number :min="0" class="bacClass" v-model="record.bulkCount" name="input" @keyup.enter="enterEvent"
                        :precision="2"></a-input-number>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          return {
            record,
            enterEvent,
          }
        },
      },
    },
    {
      dataIndex: 'bulkNumber',
      field: 'bulkNumber',
      headerName: '散件/件数',
      slotName: 'bulkNumber',
      width: 150,
      cellRenderer: {
        template: `
        <a-input-number :min="0" class="bacClass" v-model="record.bulkNumber" name="input" @change="changeEvent(record)"
                        @keyup.enter="enterEvent"
                        :precision="2"></a-input-number>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          const changeEvent = (record: any) => {
            jiHUsn3(record)
          }
          return {
            record,
            enterEvent,
            changeEvent,
          }
        },
      },
    },
    {
      dataIndex: 'bulkWeight',
      field: 'bulkWeight',
      headerName: '散件/散重',
      slotName: 'bulkWeight',
      width: 150,
      cellRenderer: {
        template: `
        <a-input-number :min="0" class="bacClass" v-model="record.bulkWeight" @change="changeEvent(record)" name="input"
                        @keyup.enter="enterEvent"
                        :precision="2"></a-input-number>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          const changeEvent = (record: any) => {
            jiHUsn3(record)
          }
          return {
            record,
            enterEvent,
            changeEvent,
          }
        },
      },
    },
    {
      dataIndex: 'weightTotal',
      field: 'weightTotal',
      headerName: '总重量',
      width: 150,
      cellRenderer: {
        template: `
        <a-input v-model="record.weightTotal" name="input" :disabled='true'></a-input>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          return {
            record,
          }
        },
      },
    },
    {
      dataIndex: 'packing',
      field: 'packing',
      headerName: '包装',
      slotName: 'packing',
      width: 150,
      cellRenderer: {
        template: `
        <a-input class="bacClass" v-model="record.packing" name="input" @keyup.enter="enterEvent"></a-input>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          return {
            record,
            enterEvent,
          }
        },
      },
    },
    {
      dataIndex: 'packingFeature',
      field: 'packingFeature',
      headerName: '包装特征',
      slotName: 'packingFeature',
      width: 150,
      cellRenderer: {
        template: `
        <a-input class="bacClass" v-model="record.packingFeature" name="input" @keyup.enter="enterEvent"></a-input>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          return {
            record,
            enterEvent,
          }
        },
      },
    },
    {
      dataIndex: 'sourceNumber',
      field: 'sourceNumber',
      headerName: '入库来源',
      width: 150,
    },
    {
      dataIndex: 'unit',
      field: 'unit',
      headerName: '单位',
      slotName: 'unit',
      width: 150,
    },
    {
      dataIndex: 'location',
      field: 'location',
      slotName: 'location',
      headerName: '库位',
      width: 150,
      cellRenderer: {
        template: `
        <a-input class="bacClass" v-model="record.location" name="input" @keyup.enter="enterEvent"></a-input>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          return {
            record,
            enterEvent,
          }
        },
      },
    },
    {
      headerName: '生产日期开始',
      field: 'productionDateStart',
      slotName: 'productionDateStart',
      width: 200,
      cellRenderer: {
        template: `
        <a-date-picker popup-container="html" v-model="record.productionDateStart" class="bacClass"
                       :style="{ width: '9rem' }"/>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          return {
            record,
          }
        },
      },
    },
    {
      headerName: '生产日期结束',
      field: 'productionDateEnd',
      slotName: 'productionDateEnd',
      width: 200,
      cellRenderer: {
        template: `
        <a-date-picker popup-container="html" v-model="record.productionDateEnd" class="bacClass"
                       :style="{ width: '9rem' }"/>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          return {
            record,
          }
        },
      },
    },
    {
      dataIndex: 'paperBone',
      field: 'paperBone',
      headerName: '纸骨',
      width: 150,
      slotName: 'paperBone',
      cellRenderer: {
        template: `
        <a-input class="bacClass" v-model="record.paperBone"></a-input>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          return {
            record,
          }
        },
      },
    },
    {
      dataIndex: 'remark',
      field: 'remark',
      slotName: 'remark',
      headerName: '备注',
      width: 150,
      cellRenderer: {
        template: `
        <a-input class="bacClass" v-model="record.remark" name="input" @keyup.enter="enterEvent"></a-input>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const enterEvent = (b: any) => {
            EnterPress(b)
          }
          return {
            record,
            enterEvent,
          }
        },
      },
    },
    {
      dataIndex: 'acFighs',
      field: 'acFighs',
      slotName: 'acFighs',
      headerName: '操作',
      pinned: 'right',
      width: 100,
      cellRenderer: {
        template: `
        <a-button type="primary" @click="clickEvent(record)" size="mini">删除</a-button>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const clickEvent = (b: any) => {
            delLine2(b)
          }
          return {
            record,
            clickEvent,
          }
        },
      },
    },
  ]
  const warehouseChange = ($event: any, record: any) => {
    if ($event != '' || $event != undefined) {
      record['warehouseId'] = Number($event.split('-')[0])
      record['warehouseName'] = $event.split('-')[1]
      return
    }
  }

  const cadelvs = () => {
    post({
      url: 'wms/yarnInStock/releaseLockByGoodsReceivingNote',
      data: {
        receiptNumber: receiptNumberS,
      },
    })
    cgOut.visible = false
  }

  const delSles = () => {
    if (gridOption.value.getSelectedRows().length == 0) {
      Message.error('请先勾选')
      return
    }
    Modal.confirm({
      title: '系统提示',
      content: '确认删除选中的数据?',
      onOk: () => {
        post({
          url: 'wms/yarnInStock/deleteByIdList',
          data: gridOption.value.getSelectedRows().map((res: any) => res.id),
        }).then((res: any) => {
          if (res.code == 200) {
            Message.success('删除成功')
            cxYcList()
          } else Message.error(res.message)
        })
      },
    })
  }

  const audits = () => {
    if (gridOption.value.getSelectedRows().length < 1) {
      Message.error('请勾选数据')
      return
    }
    Modal.confirm({
      title: '系统提示',
      content: '确认审核选中的数据?',
      onOk: () => {
        post({
          url: 'wms/yarnInStock/stockOnAuditState',
          data: gridOption.value.getSelectedRows().map((res: any) => {
            return res.id
          }),
        }).then((res: any) => {
          if (res.code == 200) {
            Message.success('成功')
            cxYcList()
          } else Message.error(res.message)
        })
      },
    })
  }

  const cgData2: any = ref([])

  const cgData3: any = ref([])

  const cgData5: any = ref([])
  const cgData6: any = ref([])
  let receiptNumberS: any

  const rouWh = (e: any) => {
    receiptNumberS = e['receiptNumber']
    post({
      url: 'wms/yarnInStock/lockByGoodsReceivingNote',
      data: {
        receiptNumber: e['receiptNumber'],
      },
    }).then((res: any) => {
      if (res.code == 200) {
        e['inStockType'] = '采购入库'
        e['customName'] = '巨丰'
        e['recordType'] = 1
        e['pieceCount'] = e['onlyCount']
        cgData2.value = [e]
        cgOut.visible = true
      } else {
        Message.error(res.message)
      }
    })
  }

  const jiHUsn = (e: any) => {
    if (e.pieceNumber == undefined) {
      e.pieceNumber = 0
    }
    if (e.pieceWeight == undefined) {
      e.pieceWeight = 0
    }
    if (e.bulkWeight == undefined) {
      e.bulkWeight = 0
    }
    if (e.bulkWeight) {
      e['weightTotal'] = e.pieceNumber * e.pieceWeight + e.bulkWeight
    } else {
      if (e.pieceWeight && e.pieceNumber != undefined) {
        e['weightTotal'] = e.pieceNumber * e.pieceWeight
      } else {
        e['weightTotal'] = 0
      }
    }
  }

  const jiHUsn2 = (e: any) => {
    if (e.pieceNumber == undefined) {
      e.pieceNumber = 0
    }
    if (e.pieceWeight == undefined) {
      e.pieceWeight = 0
    }
    if (e.bulkWeight == undefined) {
      e.bulkWeight = 0
    }
    if (e.bulkWeight) {
      e['weightTotal'] = e.pieceNumber * e.pieceWeight + e.bulkWeight
    } else {
      e['weightTotal'] = e.pieceNumber * e.pieceWeight
    }
  }

  const jiHUsn3 = (e: any) => {
    if (e.pieceNumber == undefined) {
      e.pieceNumber = 0
    }
    if (e.pieceWeight == undefined) {
      e.pieceWeight = 0
    }
    if (e.bulkWeight == undefined) {
      e.bulkWeight = 0
    }
    if (e.bulkWeight) {
      e['weightTotal'] = e.pieceNumber * e.pieceWeight + e.bulkWeight
    } else {
      if (e.pieceNumber && e.pieceWeight) {
        e['weightTotal'] = e.pieceNumber * e.pieceWeight
      }
    }
  }

  const jiHUsn4 = (e: any) => {
    if (e.bulkWeight) {
      e['weightTotal'] = e.pieceNumber * e.pieceWeight + e.bulkWeight
    } else {
      if (e.pieceNumber && e.pieceWeight != undefined) {
        e['weightTotal'] = e.pieceNumber * e.pieceWeight
      } else {
        e['weightTotal'] = 0
      }
    }
  }

  const xzylRks = () => {
    // for (let item in pageData) {
    //     pageData[item] = ''
    // }
    pageData.g = ''
    pageData.h = ''
    pageData.i = ''
    pageData.j = ''
    pageData.e = ''
    pageData.f = ''
    pageData.transportName = ''
    dbPageDate.showAdd = true
  }

  const dbPageDate: any = reactive({
    showAdd: false,
    titles: '新增原料入库',
  })

  const sideOk = async () => {
    if (cgData3.value.length == 0) {
      Message.error('请选择原料信息')
      return
    }
    // if (pageData.h == "客供入库") {
    //   if (pageData.transportName == '' || pageData.transportName == null || pageData.transportName == undefined) {
    //     Message.error('入库类型为 客供入库 ,需填写搬运类型!')
    //     return
    //   }
    // }
    for (let i = 0; i < cgData3.value.length; i++) {
      if (
        cgData3.value[i].weightTotal == '' ||
        cgData3.value[i].weightTotal == undefined ||
        cgData3.value[i].weightTotal == null ||
        cgData3.value[i].weightTotal == 0
      ) {
        Message.error('总数量必须大于0')
        return false
      }
      if (
        cgData3.value[i].inStockType == '' ||
        cgData3.value[i].inStockType == undefined ||
        cgData3.value[i].inStockType == null
      ) {
        Message.error('入库类型必填')
        return false
      }
      if (cgData3.value[i]['pieceNumber'] > 0) {
        if (
          cgData3.value[i]['pieceCount'] == '' ||
          cgData3.value[i]['pieceCount'] == undefined ||
          cgData3.value[i]['pieceCount'] == null ||
          cgData3.value[i]['pieceCount'] == 0
        ) {
          Message.error('请录入整件个数!')
          return false
        }
      }
      // if (cgData3.value[i].supplier == '' || cgData3.value[i].supplier == undefined || cgData3.value[i].supplier == null) {
      //     Message.error('供应商必填')
      //     return false
      // }
      if (
        cgData3.value[i].customName == '' ||
        cgData3.value[i].customName == undefined ||
        cgData3.value[i].customName == null
      ) {
        Message.error('客户名称必填')
        return false
      }
      if (
        pageData.transportName == '' ||
        pageData.transportName == undefined ||
        pageData.transportName == null
      ) {
        Message.error('搬运计件必填')
        return false
      }
      if (
        cgData3.value[i].yarnBrand == '' ||
        cgData3.value[i].yarnBrand == undefined ||
        cgData3.value[i].yarnBrand == null
      ) {
        Modal.confirm({
          title: '系统提示',
          content: '纱牌未填确认入库!',
          onOk: async () => {
            console.log(cgData3.value, '入库参数')
            // pageData.transportName
            const { code, message } = await post({
              url: 'wms/yarnInStock/stockInByGoodsReceivingNote',
              data: cgData3.value.map((res: any) => {
                return {
                  ...res,
                  transportName: pageData.transportName,
                }
              }),
            })
            if (code == 200) {
              cxYcList()
              cxDbsList()
              cgData3.value = []
              pageData.g = ''
              dbPageDate.showAdd = false
              Message.success('成功')
              return
            } else {
              Message.error(message)
            }
          },
        })
        return false
      }
    }
    // pageData.transportName
    const { code, message } = await post({
      url: 'wms/yarnInStock/stockInByGoodsReceivingNote',
      data: cgData3.value.map((res: any) => {
        return {
          ...res,
          transportName: pageData.transportName,
        }
      }),
    })
    if (code == 200) {
      cxYcList()
      cxDbsList()
      cgData3.value = []
      pageData.g = ''
      dbPageDate.showAdd = false
      Message.success('成功')
    } else {
      Message.error(message)
    }
  }

  const sideNo = () => {
    cgData3.value = []
    pageData.g = ''
    dbPageDate.showAdd = false
  }

  const addLine = () => {
    addType.value = '新增原料入库'
    if (pageData.g == '' || pageData.g == undefined) {
      Message.error('请先选择仓库')
      return
    }
    post({
      url: '/admin/acl/user/findUserToken',
    }).then((res) => {
      processType.value = res.data.data.judgeGroup
      visibleYl.value = true
    })
  }
  const addLine2 = () => {
    addType.value = '修改原料入库'
    post({
      url: '/admin/acl/user/findUserToken',
    }).then((res) => {
      processType.value = res.data.data.judgeGroup
      visibleYl.value = true
    })
  }
  const delLine2 = (e: any) => {
    console.log('e', e)
    Modal.confirm({
      title: '系统提示',
      content: '确认删除选中的数据?',
      onOk: () => {
        const allRowsData: any[] = []
        gridOptioncg4.value.forEachNode((node: any) => {
          allRowsData.push(node.data)
        })
        if (allRowsData.length == 1) {
          Message.error('至少保留一条数据')
          return
        }
        console.log('eid', e.id)
        if (e.id) {
          //是删除初始数据的情况
          const deletedObj: any = JSON.parse(JSON.stringify(e))
          deletedObj.deleteInfo = 1
          deletedInitData.value.push(deletedObj)
          const nowData = allRowsData.filter((val: any) => {
            return val.id != e.id
          })
          console.log('true', nowData)
          gridOptioncg4.value.setRowData(nowData)
        } else {
          const nowData = allRowsData.filter((val: any) => {
            return val != e
          })
          console.log('false', nowData)
          gridOptioncg4.value.setRowData(nowData)
        }
      },
    })
  }

  const isLyCodeds: any = ref('')
  const isLyNameds: any = ref('')
  const processType: any = ref(null)
  const wlListXqs: any = ref([])
  let tableListDatas = reactive({
    typeLesIds: 0,
  })
  const selectedRowKeys2: any = ref([])
  const whService = new WHService()

  const tableColumns3: any = [
    {
      showRowGroup: 'hide_def',
      headerName: '',
      checkboxSelection: true,
      headerCheckboxSelection: true,
      pinned: 'left',
      width: 50,
      resizable: false,
      filter: false,
      sortable: false,
      minWidth: 50,
      maxWidth: 50,
      lockPosition: 'left',
    },
    {
      dataIndex: 'rawMaterialCode',
      field: 'rawMaterialCode',
      headerName: '原料编号',
      width: 150,
    },
    {
      dataIndex: 'rawMaterialName',
      field: 'rawMaterialName',
      headerName: '原料名称',
      width: 500,
    },
    {
      dataIndex: 'brandName',
      field: 'brandName',
      headerName: '纱牌',
      width: 150,
    },
    {
      dataIndex: 'pieceWeight',
      field: 'pieceWeight',
      headerName: '整件/件重',
      width: 150,
    },
    {
      dataIndex: 'unit',
      field: 'unit',
      headerName: '单位',
      width: 150,
    },
  ]

  let idType: any = 0

  const handleOks = () => {
    if (addType.value == '新增原料入库') {
      selectedRowKeys2.value = gridtableOptioncg3.value
        .getSelectedRows()
        .map((item) => item.typeLesIds)
      console.log(selectedRowKeys2.value)

      if (selectedRowKeys2.value.length == 0) {
        Message.error('请勾选数据')
        return false
      }
      let islistArray: any = []
      for (let i = 0; i < wlListXqs.value.length; i++) {
        if (selectedRowKeys2.value.includes(wlListXqs.value[i].typeLesIds)) {
          islistArray.push(wlListXqs.value[i])
        }
      }
      // if (cgData3.value.length != 0) {
      //   let wlAarray: any = []
      //   for (let i = 0; i < islistArray.length; i++) {
      //     wlAarray.push(islistArray[i].rawMaterialCode)
      //   }
      //   for (let i = 0; i < cgData3.value.length; i++) {
      //     if (wlAarray.includes(cgData3.value[i].yarnCode)) {
      //       Message.error('请勿勾选相同原料')
      //       return false
      //     }
      //   }
      // }
      islistArray.forEach((e: any) => {
        e['yarnCode'] = e['rawMaterialCode']
        e['yarnName'] = e['rawMaterialName']
        e['yarnBrand'] = e['brandName']
        e['idType'] = idType++
        e['firm'] = pageData.e
        e['firmId'] = pageData.f
        e['warehouse'] = pageData.g.split('-')[1]
        e['warehouseId'] = Number(pageData.g.split('-')[0])
        e['recordType'] = 0
        e['inStockType'] = pageData.h
        e['customName'] = pageData.i
        e['customOrderNo'] = pageData.j
        delete e.rawMaterialCode
        delete e.rawMaterialName
        delete e.brandName
      })
      cgData3.value.push(...islistArray)
      gridOptioncg3.value.setRowData(cgData3.value)
      // setcorDisabledRefs.value.setcorDisabled(true)
      isLyCodeds.value = ''
      isLyNameds.value = ''
      wlListXqs.value = []
      selectedRowKeys2.value = []
      visibleYl.value = false

      return true
    } else if (addType.value == '修改原料入库') {
      selectedRowKeys2.value = gridtableOptioncg3.value
        .getSelectedRows()
        .map((item) => item.typeLesIds)
      console.log(selectedRowKeys2.value)

      if (selectedRowKeys2.value.length == 0) {
        Message.error('请勾选数据')
        return false
      }
      let islistArray: any = []
      for (let i = 0; i < wlListXqs.value.length; i++) {
        if (selectedRowKeys2.value.includes(wlListXqs.value[i].typeLesIds)) {
          islistArray.push(wlListXqs.value[i])
        }
      }
      // if (cgData3.value.length != 0) {
      //   let wlAarray: any = []
      //   for (let i = 0; i < islistArray.length; i++) {
      //     wlAarray.push(islistArray[i].rawMaterialCode)
      //   }
      //   for (let i = 0; i < cgData3.value.length; i++) {
      //     if (wlAarray.includes(cgData3.value[i].yarnCode)) {
      //       Message.error('请勿勾选相同原料')
      //       return false
      //     }
      //   }
      // }
      console.log('isListArray', islistArray)
      islistArray.forEach((e: any) => {
        e['yarnCode'] = e['rawMaterialCode']
        e['yarnName'] = e['rawMaterialName']
        e['yarnBrand'] = e['brandName']
        e['idType'] = idType++
        e['firm'] = editData.firmName
        e['firmId'] = editData.firmId
        e['warehouse'] = editData.warehouseName
        e['warehouseId'] = Number(editData.warehouseId)
        e['recordType'] = 0
        e['inStockType'] = editData.inStockType
        e['customName'] = editData.customName
        e['customOrderNo'] = editData.customOrderNo
        delete e.rawMaterialCode
        delete e.rawMaterialName
        delete e.brandName
      })
      const allRowsData: any[] = []
      gridOptioncg4.value.forEachNode((node: any) => {
        allRowsData.push(node.data)
      })
      allRowsData.push(...islistArray)
      gridOptioncg4.value.setRowData(allRowsData)
      // setcorDisabledRefs.value.setcorDisabled(true)
      isLyCodeds.value = ''
      isLyNameds.value = ''
      wlListXqs.value = []
      selectedRowKeys2.value = []
      visibleYl.value = false
      return true
    }
  }

  const handleCancels = () => {
    isLyCodeds.value = ''
    isLyNameds.value = ''
    wlListXqs.value = []
    selectedRowKeys2.value = []
    visibleYl.value = false
  }

  const cxCgsLists = async () => {
    // const res: any = await whService.wlCxMxSmWhmxWarhouse({
    //     rawmaterialCode: isLyCodeds.value,
    //     materialsName: isLyNameds.value,
    //     auditState: 1
    // })
    const res: any = await post({
      url: 'product/Rawmaterial/getListByWarehouse',
      data: {
        page: fySelet5.page,
        size: fySelet5.size,
        rawmaterialCode: isLyCodeds.value,
        materialsName: isLyNameds.value,
        auditState: 1,
        outsideState: processType.value,
      },
    })
    if (res.code == 200) {
      fySelet5.total = res.data.total
      wlListXqs.value = res.data.list
      wlListXqs.value.forEach((item: any) => {
        item['typeLesIds'] = tableListDatas.typeLesIds++
      })
    }
  }
  const configCascader2 = ref<{}>({
    corporateWidth: '200px', //公司宽度
    corporateNameLabelWidth: '80px',
    sectorWidth: '180px', //部门宽度
    corporateRquired: false, //公司是否必填
    sectorRquired: false, //部门是否必填
    size: 'mini', //选择框大小'mini' | 'small' | 'medium' | 'large'
    corporateName: '选择公司', //公司label
    sectorName: '选择部门', //部门label
    cascaderShow: 'sector', //配置部门不显示
  })
  const changeCascader2 = (data: any) => {
    const { corporateId, sectorId, sectorLabel, corporateLabel } = data
    pageData.b = ''
    pageData.a = corporateId
    whService.getWarhouseListByFirmId(corporateId, '原纱仓')
  }

  const configCascader = ref<{}>({
    corporateWidth: '200px', //公司宽度
    sectorWidth: '180px', //部门宽度
    corporateRquired: true, //公司是否必填
    sectorRquired: false, //部门是否必填
    size: 'mini', //选择框大小'mini' | 'small' | 'medium' | 'large'
    corporateName: '选择公司', //公司label
    sectorName: '选择部门', //部门label
    cascaderShow: 'sector', //配置部门不显示
  })

  const fhWhList: any = whService.whList
  const changeCascader = (data: any) => {
    const { corporateId, sectorId, sectorLabel, corporateLabel } = data
    pageData.g = ''
    pageData.e = corporateLabel
    pageData.f = corporateId
    whService.getWarhouseListByFirmId(corporateId, '原纱仓')
    nextTick(() => {
      if (data.corporateList.length == 1 && !data.corporateList[0].children) {
        const fhUhlist = fhWhList.value[0]
        pageData.g = fhUhlist.id + '-' + fhUhlist.warehouseName
      }
    })
  }

  const inStoCxList: any = ref([])

  const inStoCx = () => {
    if (!pageData.g) {
      Message.info('请先选择仓库')
      return
    }
    post({
      url: 'wms/stockinType/getStockinTypePage',
      data: {
        page: 1,
        size: 1000,
        warehouseId: Number(pageData.g.split('-')[0]),
      },
    }).then((res: any) => {
      if (res.code == 200) {
        inStoCxList.value = res.data.list.filter((o:any)=> o.typeName != '转料虚拟入库' && o.typeName != '虚拟入库')
      }
    })
  }

  const supplierCxList: any = ref([])

  const supplierCx = () => {
    post({
      url: 'purchase/Provider/getFieldValue',
      data: {
        providerName: '',
      },
    }).then((res: any) => {
      if (res.code == 200) {
        supplierCxList.value = res.data
      }
    })
  }

  const customNameCxList: any = ref([])

  const customName = (value: any) => {
    post({
      url: 'product/Brand/getFieldValue',
      data: {
        brandName: value,
      },
    }).then((res: any) => {
      if (res.code == 200) {
        customNameCxList.value = res.data
      }
    })
  }

  const laveChang = (e: any) => {
    if (window.encodeURI(e.level).indexOf('%') != -1) {
      Message.error('填写的值不能包含中文')
      e.level = ''
    }
    // if (e.level.replace(/[^a-zA-Z]/g, '') == '') {
    //     Message.error('请输入英文')
    // }
    // e.level = e.level.replace(/[^a-zA-Z]/g, '').toUpperCase()
    e.level = e.level.toUpperCase()
  }

  const matchColorChang = (e: any) => {
    if (window.encodeURI(e.matchColor).indexOf('%') == -1) {
      Message.error('请输入中文')
      e.matchColor = ''
    }
  }
  // window.encodeURI(value).indexOf('%') !== -1
  const colorCodeColorChang = (e: any) => {
    if (window.encodeURI(e.colorCode).indexOf('%') != -1) {
      Message.error('输入不合法')
      e.colorCode = ''
    } else {
      e.colorCode = e.colorCode.toUpperCase()
    }
  }

  const colorNameChang = (e: any) => {
    if (window.encodeURI(e.colorName).indexOf('%') == -1) {
      Message.error('请输入中文')
      e.colorName = ''
    }
  }
  const fySelet: any = reactive({
    total: 10,
    size: 10,
    page: 1,
  })

  const PageSize = (val: any) => {
    fySelet.page = val
    cxCgsList()
  }

  const change = (val: any) => {
    fySelet.size = val
    cxCgsList()
  }
  const cxCgsList = () => {
    if (pageData.dropDownTime.length == 0) {
      var startDate = ''
      var endDate = ''
    } else {
      var startDate = pageData.dropDownTime[0]
      var endDate = pageData.dropDownTime[1]
    }
    post({
      url: 'wms/yarnTransferStock/getPage',
      data: {
        page: fySelet.page,
        size: fySelet.size,
        queryType: '1',
        infoState: 1,
        inFirmId: pageData.a,
        inWarehouseId: pageData.b,
        yarnCode: pageData.yarnCode,
        yarnName: pageData.yarnName,
        yarnBrand: pageData.yarnBrand,
        productionBatch: pageData.productionBatch,
        level: pageData.level,
        orderType: pageData.orderType ? pageData.orderType : null,
        sourceNumber: pageData.sourceNumber, //来源单号
        startDate: compareDate(startDate, endDate) == true ? endDate : startDate,
        endDate: compareDate(startDate, endDate) == true ? startDate : endDate,
      },
    }).then((res: any) => {
      setTableTotalRow(gridOption2, res.data.list, [
        'pieceNumber',
        'bulkNumber',
        'bulkWeight',
        'weightTotal',
      ])
      gridOption2.value.setRowData(res.data.list)
      tableDataList2.value = res.data.list
      fySelet.total = res.data.total
    })
  }

  const fySelet4: any = reactive({
    total: 10,
    size: 10,
    page: 1,
  })

  const PageSize4 = (val: any) => {
    fySelet4.page = val
    cxCgsList2()
  }

  const change4 = (val: any) => {
    fySelet4.size = val
    cxCgsList2()
  }
  const fySelet5: any = reactive({
    total: 10,
    size: 10,
    page: 1,
  })

  const PageSize5 = (val: any) => {
    fySelet5.page = val
    cxCgsLists()
  }

  const change5 = (val: any) => {
    fySelet5.size = val
    cxCgsLists()
  }

  const fySelet6: any = reactive({
    total: 10,
    size: 10,
    page: 1,
  })

  const PageSize6 = (val: any) => {
    fySelet6.page = val
    cjOutIntSelect()
  }

  const change6 = (val: any) => {
    fySelet6.size = val
    cjOutIntSelect()
  }

  const cjOutIntSelect = () => {
    if (pageData.dropDownTime1.length == 0) {
      var startDate = ''
      var endDate = ''
    } else {
      var startDate = pageData.dropDownTime1[0]
      var endDate = pageData.dropDownTime1[1]
    }
    post({
      url: 'qms/MaterialReturnGather/getPageByInStoke',
      data: {
        page: fySelet6.page,
        size: fySelet6.size,
        planOrderCode: pageData.prodCode,
        customName: pageData.khName,
        startDate: compareDate(startDate, endDate) == true ? endDate : startDate,
        endDate: compareDate(startDate, endDate) == true ? startDate : endDate,
        materialReturnCode: pageData.materialReturnCode,
      },
    }).then((res: any) => {
      setTableTotalRow(gridOption5, res.data.list, [
        'pieceNumber',
        'bulkCount',
        'bulkNumber',
        'bulkWeight',
        'weightTotal',
        'stockPieceNum',
        'stockBulkCount',
        'stockBulkNum',
        'stockBulkWeight',
      ])
      gridOption5.value.setRowData(res.data.list)
      fySelet6.total = res.data.total
    })
  }

  const cxCgsList2 = () => {
    if (pageData.dropDownTime.length == 0) {
      var startDate = ''
      var endDate = ''
    } else {
      var startDate = pageData.dropDownTime[0]
      var endDate = pageData.dropDownTime[1]
    }
    post({
      url: 'wms/yarnTransferStock/getPage',
      data: {
        page: fySelet4.page,
        size: fySelet4.size,
        queryType: '1',
        infoState: 2,
        inFirmId: pageData.a,
        inWarehouseId: pageData.b,
        yarnCode: pageData.yarnCode,
        yarnName: pageData.yarnName,
        yarnBrand: pageData.yarnBrand,
        productionBatch: pageData.productionBatch,
        level: pageData.level,
        orderType: pageData.orderType ? pageData.orderType : null,
        sourceNumber: pageData.sourceNumber, //来源单号
        startDate: compareDate(startDate, endDate) == true ? endDate : startDate,
        endDate: compareDate(startDate, endDate) == true ? startDate : endDate,
      },
    }).then((res: any) => {
      setTableTotalRow(gridOption4, res.data.list, [
        'pieceNumber',
        'bulkNumber',
        'bulkWeight',
        'weightTotal',
      ])
      gridOption4.value.setRowData(res.data.list)
      tableDataList4.value = res.data.list
      fySelet4.total = res.data.total
    })
  }
  const tableDataList2 = ref([])
  const defaultColDef2 = {
    sortable: true,
    resizable: true,
    filter: true,
  }
  const gridOption2 = ref()
  const colState2 = ref()
  const gridReady2 = (params: any) => {
    gridOption2.value = params.api
    colState2.value = params.columnApi
  }
  const tableDataList4: any = ref([])
  const gridOption4 = ref()
  const colState4 = ref()
  const gridReady4 = (params: any) => {
    gridOption4.value = params.api
    colState4.value = params.columnApi
  }

  const tableDataList5: any = ref([])
  const gridOption5 = ref()
  const colState5 = ref()
  const gridReady5 = (params: any) => {
    gridOption5.value = params.api
    colState5.value = params.columnApi
  }

  const tc2 = [
    {
      showRowGroup: 'hide_def',
      headerName: '',
      checkboxSelection: true,
      headerCheckboxSelection: true,
      pinned: 'left',
      width: 50,
      resizable: false,
      filter: false,
      sortable: false,
      minWidth: 50,
      maxWidth: 50,
      lockPosition: 'left',
    },
    {
      headerName: '调拨申请单号',
      field: 'applicationNumber',
      width: 150,
    },
    {
      headerName: '调拨单号',
      field: 'transferNumber',
      // pinned: o['fixed'],
      width: 150,
    },
    {
      headerName: '转出公司',
      field: 'outFirm',
      // pinned: o['fixed'],
      width: 150,
    },
    {
      headerName: '转出仓库',
      field: 'outWarehouse',
      width: 150,
    },
    {
      headerName: '收货公司',
      field: 'inFirm',
      width: 150,
    },
    {
      headerName: '收货仓库',
      field: 'inWarehouse',
      width: 150,
    },
    {
      headerName: '来源单号',
      field: 'sourceNumber',
      width: 150,
    },
    // {
    //     headerName: '调拨单号',
    //     field: 'transferNumber',
    //     width: 150
    // },
    {
      headerName: '贸易商',
      field: 'trader',
      width: 150,
    },
    {
      headerName: '库存组织',
      field: 'inventoryOrganization',
      width: 150,
    },
    {
      headerName: '搬运计件',
      field: 'transportName',
      width: 150,
    },
    {
      headerName: '客户名称',
      field: 'customName',
      width: 150,
    },
    {
      headerName: '原料编号',
      field: 'yarnCode',
      width: 150,
    },
    {
      headerName: '原料名称',
      field: 'yarnName',
      width: 150,
    },
    {
      headerName: '纱牌',
      field: 'yarnBrand',
      width: 150,
    },
    {
      headerName: '纱批',
      field: 'productionBatch',
      width: 150,
    },
    {
      headerName: '等级',
      field: 'level',
      width: 150,
    },
    // {
    //     headerName: '可配色称',
    //     field: 'matchColor',
    //     width: 150
    // },
    {
      headerName: '色号',
      field: 'colorCode',
      width: 150,
    },
    {
      headerName: '色称',
      field: 'colorName',
      width: 150,
    },
    {
      headerName: '整件/件数',
      field: 'pieceNumber',
      width: 150,
    },
    {
      headerName: '整件/件重',
      field: 'pieceWeight',
      width: 150,
    },
    {
      headerName: '散件/件数',
      field: 'bulkNumber',
      width: 150,
    },
    {
      headerName: '散件/散重',
      field: 'bulkWeight',
      width: 150,
    },
    {
      headerName: '总数量',
      field: 'weightTotal',
      width: 150,
    },
    {
      headerName: '单位',
      field: 'unit',
      width: 150,
    },
    {
      headerName: '纸骨',
      field: 'paperBone',
      width: 150,
    },
    {
      headerName: '包装',
      field: 'packing',
      width: 150,
    },
    {
      headerName: '库位',
      field: 'location',
      width: 150,
    },
    {
      headerName: '出库时间',
      field: 'outDate',
      width: 150,
    },
    {
      headerName: '出库人',
      field: 'outName',
      width: 150,
    },
    {
      headerName: '收货时间',
      field: 'inDate',
      width: 150,
    },
    {
      headerName: '收货人',
      field: 'inName',
      width: 150,
    },
    {
      headerName: '创单人',
      field: 'createName',
      width: 150,
    },
    {
      headerName: '创单时间',
      field: 'createDate',
      width: 150,
    },
    {
      headerName: '单据备注',
      field: 'remark',
      width: 150,
    },
    {
      headerName: '明细备注',
      field: 'detailRemake',
      width: 150,
    },
    {
      headerName: '生产日期开始',
      field: 'productionDateStart',
      width: 150,
    },
    {
      headerName: '生产日期结束',
      field: 'productionDateEnd',
      width: 150,
    },
    {
      headerName: '单据类型',
      field: 'orderType',
      width: 150,
      pinned: 'right',
      cellRenderer: {
        template: `
        <a-space>
          <a-tag color="#f53f3f" style="position:relative;left:6px" v-if="infoState==0">普通调拨单</a-tag>
          <a-tag style="position:relative;left:6px" color="green" v-if="infoState==1">加工出库单</a-tag>
          <a-tag style="position:relative;left:6px" color="green" v-if="infoState==2">加工领料单</a-tag>
          <a-tag style="position:relative;left:6px" color="green" v-if="infoState==3">加工收货单</a-tag>
          <a-tag style="position:relative;left:6px" color="green" v-if="infoState==4">纱线转让单</a-tag>
          <a-tag style="position:relative;left:6px" color="green" v-if="infoState==5">采购退货单</a-tag>
        </a-space>
      `,
        setup(props: any) {
          const a = () => {
            rouWh(props.params.data)
          }
          return {
            a,
            infoState: props.params.data.orderType,
          }
        },
      },
      filterParams: {
        valueFormatter: function (params: any) {
          return params.value == '0'
            ? '普通调拨单'
            : params.value == '1'
            ? '加工出库单'
            : params.value == '2'
            ? '加工领料单'
            : params.value == '3'
            ? '加工收货单'
            : params.value == '4'
            ? '纱线转让单'
            : params.value == '5'
            ? '采购退货单'
            : ''
        },
      },
    },
    {
      headerName: '单据状态',
      field: 'infoState',
      width: 110,
      pinned: 'right',
      cellRenderer: {
        template: `
        <a-space>
          <a-tag color="#f53f3f" style="position:relative;left:6px" v-if="infoState==0">未审核</a-tag>
          <a-tag style="position:relative;left:6px" color="green" v-if="infoState==1">已出库</a-tag>
          <a-tag style="position:relative;left:6px" color="green" v-if="infoState==2">已收货</a-tag>
        </a-space>
      `,
        setup(props: any) {
          const a = () => {
            rouWh(props.params.data)
          }
          return {
            a,
            infoState: props.params.data.infoState,
          }
        },
      },
      filterParams: {
        valueFormatter: function (params: any) {
          return params.value == '0'
            ? '未审核'
            : params.value == '1'
            ? '已出库'
            : params.value == '2'
            ? '已收货'
            : ''
        },
      },
    },
  ]

  const cgData4: any = ref([])

  const cgColumns4: any = [
    {
      dataIndex: 'transferNumber',
      field: 'transferNumber',
      headerName: '调拨单号',
      width: 150,
    },
    {
      dataIndex: 'outFirm',
      field: 'outFirm',
      headerName: '转出公司',
      width: 150,
    },
    {
      dataIndex: 'outWarehouse',
      field: 'outWarehouse',
      headerName: '转出仓库',
      width: 150,
    },
    {
      dataIndex: 'inFirm',
      field: 'inFirm',
      headerName: '收货公司',
      width: 150,
    },
    {
      dataIndex: 'inWarehouse',
      field: 'inWarehouse',
      headerName: '收货仓库',
      width: 150,
    },
    {
      dataIndex: 'sourceNumber',
      field: 'sourceNumber',
      headerName: '来源单号',
      width: 150,
    },
    {
      dataIndex: 'transferNumber',
      field: 'transferNumber',
      headerName: '调拨单号',
      width: 150,
    },
    {
      dataIndex: 'transportName',
      field: 'transportName',
      headerName: '搬运计件',
      width: 150,
      slotName: 'transportName',
      cellRenderer: {
        template: `
        <a-select popup-container="html" class="bacClass" v-model="record.transportName" allow-clear allow-search
                  @focus="focusEvent"
                  style="width: 200px" :title="record.transportName">
          <a-option v-for="(item, index) in pageData.transportNameList" :value="item.transportName">{{
              item.transportName
            }}
          </a-option>
        </a-select>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const focusEvent = (e) => {
            focusTransportName(e)
          }
          return {
            record,
            focusEvent,
            pageData,
          }
        },
      },
    },
    {
      dataIndex: 'trader',
      field: 'trader',
      headerName: '贸易商',
      width: 150,
    },
    {
      dataIndex: 'inventoryOrganization',
      field: 'inventoryOrganization',
      headerName: '库存组织',
      width: 150,
    },
    {
      dataIndex: 'customName',
      field: 'customName',
      headerName: '客户名称',
      width: 150,
    },
    {
      dataIndex: 'yarnCode',
      field: 'yarnCode',
      headerName: '原料编号',
      width: 150,
    },
    {
      dataIndex: 'yarnName',
      field: 'yarnName',
      headerName: '原料名称',
      width: 150,
    },
    {
      dataIndex: 'yarnBrand',
      field: 'yarnBrand',
      headerName: '纱牌',
      width: 150,
    },
    {
      dataIndex: 'productionBatch',
      field: 'productionBatch',
      headerName: '纱批',
      width: 150,
    },
    {
      dataIndex: 'level',
      field: 'level',
      headerName: '等级',
      width: 150,
    },
    // {
    //     dataIndex: 'matchColor',
    //     field: 'matchColor',
    //     headerName: '可配色称',
    //     width: 150,
    // },
    {
      dataIndex: 'colorCode',
      field: 'colorCode',
      headerName: '色号',
      width: 150,
    },
    {
      dataIndex: 'colorName',
      field: 'colorName',
      headerName: '色称',
      width: 150,
    },

    {
      field: 'paperBone',
      headerName: '纸骨',
      width: 200,
      cellRenderer: {
        template: `
        <a-select popup-container="html" class="bacClass" @click="clickEvent()" :style="{ width: '10rem' }"
                  v-model="record.paperBone"
                  allow-search allow-clear allow-create @search="clickEvent()" name="input"
                  @keyup.enter="clickEvent()">
          <a-option v-for="item in paperBoneList" :value="item">
            {{ item }}
          </a-option>
        </a-select>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const paperBoneList = ref([])
          const clickEvent = () => {
            const {
              yarnCode,
              yarnBrand,
              productionBatch,
              matchColor,
              colorCode,
              colorName,
              paperBone,
            } = record.value
            post({
              url: 'wms/yarnTransferStockDetail/getPaperBoneByDetail',
              data: {
                yarnCode,
                yarnBrand,
                productionBatch,
                matchColor,
                colorCode,
                colorName,
                paperBone,
              },
            }).then((res: any) => {
              if (res.code === 200) {
                paperBoneList.value = res.data
              } else {
                Message.error(res.message)
              }
            })
          }

          return {
            record,
            paperBoneList,
            clickEvent,
            Message,
          }
        },
      },
    },
    {
      dataIndex: 'pieceNumber',
      field: 'pieceNumber',
      headerName: '整件/件数',
      width: 150,
      slotName: 'pieceNumber',
      cellRenderer: {
        template: `
        <a-input-number @change="changeEvent" class="bacClass" :min="0"
                        v-model="record.pieceNumber"></a-input-number>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const changeEvent = () => {
            cahngesCount3(record)
          }
          return {
            record,
            changeEvent,
          }
        },
      },
    },
    {
      dataIndex: 'pieceWeight',
      field: 'pieceWeight',
      headerName: '整件/件重',
      width: 150,
    },
    {
      dataIndex: 'bulkNumber',
      field: 'bulkNumber',
      headerName: '散件/件数',
      width: 150,
      slotName: 'bulkNumber',
      cellRenderer: {
        template: `
        <a-input-number class="bacClass" v-model="record.bulkNumber" :min="0"></a-input-number>

      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          return {
            record,
          }
        },
      },
    },
    {
      dataIndex: 'bulkWeight',
      field: 'bulkWeight',
      headerName: '散件/散重',
      width: 150,
      slotName: 'bulkWeight',
      cellRenderer: {
        template: `
        <a-input-number @change="changeEvent" class="bacClass" v-model="record.bulkWeight"
                        :min="0"></a-input-number>
      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          const changeEvent = () => {
            cahngesCount3(record)
          }
          return {
            record,
            changeEvent,
          }
        },
      },
    },
    {
      dataIndex: 'weightTotal',
      field: 'weightTotal',
      headerName: '总数量',
      width: 150,
    },
    {
      dataIndex: 'unit',
      field: 'unit',
      headerName: '单位',
      width: 150,
    },
    {
      dataIndex: 'location',
      field: 'location',
      headerName: '库位',
      width: 150,
    },
    {
      dataIndex: 'outDate',
      field: 'outDate',
      headerName: '出库时间',
      width: 150,
    },
    {
      dataIndex: 'productionDateStart',
      field: 'productionDateStart',
      headerName: '生产日期开始',
      width: 200,
      slotName: 'productionDateStart',
      cellRenderer: {
        template: `
        <a-date-picker popup-container="html" v-model="record.productionDateStart"/>

      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          return {
            record,
          }
        },
      },
    },
    {
      dataIndex: 'productionDateEnd',
      field: 'productionDateEnd',
      headerName: '生产日期结束',
      width: 200,
      slotName: 'productionDateEnd',
      cellRenderer: {
        template: `
        <a-date-picker popup-container="html" v-model="record.productionDateEnd"/>

      `,
        setup(props: any) {
          const record = ref()
          record.value = props.params.data
          return {
            record,
          }
        },
      },
    },
    {
      dataIndex: 'outName',
      field: 'outName',
      headerName: '出库人',
      width: 150,
    },
    {
      dataIndex: 'inDate',
      field: 'inDate',
      headerName: '收货时间',
      width: 150,
    },
    {
      dataIndex: 'inName',
      field: 'inName',
      headerName: '收货人',
      width: 150,
    },
    {
      dataIndex: 'createName',
      field: 'createName',
      headerName: '创单人',
      width: 150,
    },
    {
      dataIndex: 'createDate',
      field: 'createDate',
      headerName: '创单时间',
      width: 150,
    },
    {
      dataIndex: 'remark',
      field: 'remark',
      headerName: '单据备注',
      width: 150,
    },
    {
      dataIndex: 'detailRemake',
      field: 'detailRemake',
      headerName: '明细备注',
      width: 150,
    },
  ]

  const cgHandleOk2 = async () => {
    for (let i = 0; i < cgData4.value.length; i++) {
      if (
        cgData4.value[i]['transportName'] == '' ||
        cgData4.value[i]['transportName'] == undefined ||
        cgData4.value[i]['transportName'] == null
      ) {
        Message.error('搬运计件必填!')
        return false
      }
    }
    const params = cgData4.value.map((item: any) => {
      return {
        ...item,
        productionDateStart: dayjs(new Date(item.productionDateStart)).format(
          'YYYY-MM-DD HH:mm:ss.SSS'
        ),
        productionDateEnd: dayjs(new Date(item.productionDateEnd)).format(
          'YYYY-MM-DD HH:mm:ss.SSS'
        ),
      }
    })
    const { code, message } = await post({
      url: 'wms/yarnTransferStock/yarnTransferInStock',
      data: params,
    })
    if (code == 200) {
      cxCgsList()
      Message.success('成功')
      return true
    }
    Message.error(message)
    return false
  }

  const cadelvs2 = () => {
    cgData4.value = []
    cgOut.visible2 = false
  }

  const yarnBrandList: any = ref([])
  const productionBatchLisy: any = ref([])

  const getYarnBrandListOrProductionBatchLisy = (record: any, num: any) => {
    post({
      url: 'wms/yarnStock/getPage',
      data: {
        page: 1,
        size: 100,
        warehouse_id: pageData.g.split('-')[0],
        yarn_code: record.yarnCode,
        yarn_name: record.yarnName,
        custom_name: record.customName,
        supplier: record.supplier,
      },
    }).then((res: any) => {
      if (res.code == 200) {
        if (num == 1) {
          let temp: any = []
          let tempList: any = []
          //yarnBrand
          res.data.list.forEach(function (o: any) {
            if (!temp.includes(o.yarnBrand)) {
              tempList.push(o)
              temp.push(o.yarnBrand)
            }
          })
          yarnBrandList.value = tempList
        } else if (num == 2) {
          //productionBatch
          let temp: any = []
          let tempList: any = []
          res.data.list.forEach(function (o: any) {
            if (!temp.includes(o.productionBatch)) {
              tempList.push(o)
              temp.push(o.productionBatch)
            }
          })
          productionBatchLisy.value = tempList
        }
      }
    })
  }

  const yarnBrandClick = (record: any) => {
    getYarnBrandListOrProductionBatchLisy(record, 1)
  }

  const productionBatchClick = (record: any) => {
    getYarnBrandListOrProductionBatchLisy(record, 2)
  }
  const rowChange = ($event: any, num: any) => {
    cgData3.value.forEach((res: any) => {
      if (num == 1) {
        res.inStockType = $event
      }
      if (num == 2) {
        res.customName = $event
      }
      if (num == 3) {
        res.customOrderNo = $event
      }
      if (num == 4) {
        res.transportName = $event
      }
    })
  }
  const setcorDisabledRefs = ref()

  watch(
    () => {
      return cgData3.value.length
    },
    () => {
      if (cgData3.value.length > 0) {
        setcorDisabledRefs.value.setcorDisabled(true)
      } else {
        setcorDisabledRefs.value.setcorDisabled(false)
      }
    }
  )

  // const configFirmId = ref(null)

  // const InitialCompanys = (data:any)=>{
  //      if(data.length == 1&&!data[0].children){
  //         configFirmId.value = data[0].value
  //      }
  // }
  const toFixedNum = (num: number) => {
    return parseFloat(num.toFixed(2))
  }
  const cahngesCount3 = (record: any) => {
    const data = record.value
    if (data.pieceNumber && data.pieceNumber != 0 && data.pieceWeight && data.pieceWeight != 0) {
      nextTick(() => {
        record.value.weightTotal = toFixedNum(data.pieceNumber * data.pieceWeight + data.bulkWeight)
      })
    } else {
      nextTick(() => {
        record.value.weightTotal = toFixedNum(data.bulkWeight)
      })
    }
    let listData: any[] = []
    gridOption6.value.forEachNode((node: any) => {
      listData.push(node.data)
    })
    nextTick(() => {
      gridOption6.value.setRowData(listData)
    })
  }
  const cahngesCount4 = (record: any) => {
    const data = record.value
    if (data.pieceNumber && data.pieceNumber != 0 && data.pieceWeight && data.pieceWeight != 0) {
      nextTick(() => {
        record.value.weightTotal = toFixedNum(data.pieceNumber * data.pieceWeight + data.bulkWeight)
      })
    } else {
      nextTick(() => {
        record.value.weightTotal = toFixedNum(data.bulkWeight)
      })
    }
    let listData: any[] = []
    cgColumns2Option.value.forEachNode((node: any) => {
      listData.push(node.data)
    })
    nextTick(() => {
      cgColumns2Option.value.setRowData(listData)
    })
  }
  const cahngesCount7 = (record: any) => {
    const data = record.value
    if (data.pieceNumber && data.pieceNumber != 0 && data.pieceWeight && data.pieceWeight != 0) {
      nextTick(() => {
        record.value.weightTotal = toFixedNum(data.pieceNumber * data.pieceWeight + data.bulkWeight)
      })
    } else {
      nextTick(() => {
        record.value.weightTotal = toFixedNum(data.bulkWeight)
      })
    }
    let listData: any[] = []
    gridOption7.value.forEachNode((node: any) => {
      listData.push(node.data)
    })
    nextTick(() => {
      gridOption7.value.setRowData(listData)
    })
  }
  function handleSearch(e: any, val: any) {
    val.yarnBrand = e
  }

  function handleSearch1(e: any, val: any) {
    val.productionBatch = e
  }

  function handleSearch2(e: any, val: any) {
    val.supplier = e
  }

  const compareDate = (dateTime1: any, dateTime2: any) => {
    var formatDate1 = new Date(dateTime1)
    var formatDate2 = new Date(dateTime2)
    if (formatDate1 > formatDate2) {
      return true
    } else {
      return false
    }
  }
  const onSelect = (dateString: any, date: any) => {
    pageData.dropDownTime = {
      startDate: dateString[0],
      endDate: dateString[1],
    }
  }
  const onSelect1 = (dateString: any, date: any) => {
    pageData.dropDownTime1 = {
      startDate: dateString[0],
      endDate: dateString[1],
    }
  }
  const onClear = () => {
    pageData.dropDownTime = []
  }
  const onClear1 = () => {
    pageData.dropDownTime1 = []
  }

  const EnterPress = (e: any) => {
    const inputs = document.getElementsByName('input') // inputs 里存放了所有name为input的html元素
    inputs.forEach((input, index) => {
      if (e.currentTarget === input) {
        // 通过循环判断来获取当前输入框的index下标，进行相关操作
        if (index !== inputs.length - 1) {
          inputs[index + 1].focus()
        }
      }
    })
  }

  const cahngesCount1 = (record: any) => {
    if (record.pieceNumber && record.bulkWeight && record.pieceWeight != 0) {
      nextTick(() => {
        record.weightTotal = record.pieceNumber * record.pieceWeight + record.bulkWeight
      })
    } else if (record.pieceNumber && record.pieceWeight != 0) {
      nextTick(() => {
        record.weightTotal = record.pieceNumber * record.pieceWeight
      })
    } else if (record.bulkWeight) {
      nextTick(() => {
        record.weightTotal = record.bulkWeight
      })
    } else {
      nextTick(() => {
        record.weightTotal = 0
      })
    }
  }

  //搬运计件下拉框
  function focusTransportName() {
    get({
      url: 'pieceData/transportPrice/selectTransportPriceMovingYarn',
      data: {},
    }).then((res: any) => {
      if (res.code == 200) {
        pageData.transportNameList = res.data.list
      } else {
        Message.error(res.message)
      }
    })
  }

  //取消审核
  const cancelAudit = () => {
    if (tabsKeys.value == 1) {
      if (gridOption.value.getSelectedRows().length == 0) {
        Message.error('请选择需要取消审核的数据')
        return
      }
      Modal.confirm({
        title: '提示',
        content: '是否确认取消审核',
        onOk: async () => {
          const ids = gridOption.value.getSelectedRows().map((item: any) => {
            return item.inStockNumber
          })
          const res = await post({
            url: 'wms/yarnInStock/stockOnUnAuditState',
            data: ids,
          })
          try {
            if (res.code == 200) {
              Message.success('取消审核成功')
              cxYcList()
            } else {
              Message.error(res.message)
            }
          } catch (e) {
            console.log(e)
          }
        },
      })
    } else if (tabsKeys.value == 4) {
      if (gridOption4.value.getSelectedRows().length == 0) {
        Message.error('请选择需要取消审核的数据')
        return
      }
      Modal.confirm({
        title: '提示',
        content: '是否确认取消审核',
        onOk: async () => {
          const ids = gridOption4.value.getSelectedRows().map((item: any) => {
            return item.id
          })
          const res = await post({
            url: 'wms/yarnTransferStock/cancelYarnTransferInStock',
            data: ids,
          })
          try {
            if (res.code == 200) {
              Message.success('取消审核成功')
              cxCgsList2()
            } else {
              Message.error(res.message)
            }
          } catch (e) {
            console.log(e)
          }
        },
      })
    }
  }
const whChange = async () =>{
  await getInStock()
  if(pageData.inStockList.length > 0){
    pageData.inStockTypes = pageData.inStockList.filter((o:any)=> o != '转料虚拟入库' && o != '虚拟入库')
  }
}
  //入库类型下拉
  const getInStock  = async () =>{
    const res = await post({
        url: 'wms/stockinType/getStockinTypePage',
        data: {
          page: 1, 
          size: 1000, 
          firmId: pageData.a, 
          warehouseId: pageData.b
        },
      })
      if (res.code == 200) {
        let list = []
          for (let i = 0; i < res.data.list.length; i++) {
            var ob = res.data.list[i].typeName
            list.push(ob)
          }
          const arr = list
          const setData = Array.from(new Set(arr));
          pageData.inStockList = setData
      } else {
        Message.error(res.message)
      }
  }
  const { saveGridState: saveGridState01, updateGridState: updateGridState01 } =
    saveOrUpdateGridState01('ReceiptList3-1', gridOption, colState, tc)
  const onColumnMoved = () => {
    saveGridState01()
  }
  const onColumnResized = () => {
    saveGridState01()
  }
  const onColumnVisible = () => {
    saveGridState01()
  }
  const { saveGridState: saveGridState02, updateGridState: updateGridState02 } =
    saveOrUpdateGridState02('ReceiptList3-2', gridOption2, colState2, tc2)
  const onColumnMoved2 = () => {
    saveGridState02()
  }
  const onColumnResized2 = () => {
    saveGridState02()
  }
  const onColumnVisible2 = () => {
    saveGridState02()
  }
  const { saveGridState: saveGridState03, updateGridState: updateGridState03 } =
    saveOrUpdateGridState03('ReceiptList3-3', gridOption3, colState3, tc3)
  const onColumnMoved3 = () => {
    saveGridState03()
  }
  const onColumnResized3 = () => {
    saveGridState03()
  }
  const onColumnVisible3 = () => {
    saveGridState03()
  }
  const { saveGridState: saveGridState04, updateGridState: updateGridState04 } =
    saveOrUpdateGridState04('ReceiptList3-4', gridOption4, colState4, tc2)
  const onColumnMoved4 = () => {
    saveGridState04()
  }
  const onColumnResized4 = () => {
    saveGridState04()
  }
  const onColumnVisible4 = () => {
    saveGridState04()
  }
  const { saveGridState: saveGridState05, updateGridState: updateGridState05 } =
    saveOrUpdateGridState05('ReceiptList3-5', gridOption5, colState5, tc5)
  const onColumnMoved5 = () => {
    saveGridState05()
  }
  const onColumnResized5 = () => {
    saveGridState04()
  }
  const onColumnVisible5 = () => {
    saveGridState05()
  }
</script>

<style scoped>
  :deep(.arco-table-td-content) {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .cgisDatas {
    width: 60%;
    display: flex;
    justify-content: space-between;
  }

  :deep(.arco-picker input) {
    padding-left: 0 !important;
  }

  :deep(.arco-picker) {
    padding-left: 0 !important;
  }

  :deep(.arco-picker-separator) {
    padding: 0 !important;
  }
</style>
